下面的代码不工作
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
NSURL *url = [NSURL URLWithString:@"http://54.254.248.1/app/webroot/uploads/question_files/2017.04.20.13.43.45video.mp4"];
AVURLAsset *asset = [AVURLAsset assetWithURL: url];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset: asset];
AVPlayer * player = [[AVPlayer alloc] initWithPlayerItem: item];
playerViewController.player = player;
[playerViewController.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width)];
playerViewController.showsPlaybackControls = YES;
[self.view addSubview:playerViewController.view];
[player play];发布于 2017-05-04 13:44:18
我像这样修改您的代码,它可以工作:
NSURL *url = [NSURL URLWithString:@"http://54.254.248.1/app/webroot/uploads/question_files/2017.04.20.13.43.45video.mp4"];
AVPlayer * player = [AVPlayer playerWithURL:url];
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
playerViewController.player = player;
[playerViewController.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width)];
playerViewController.showsPlaybackControls = YES;
[self.view addSubview:playerViewController.view];
[player play];有关AVPlayerViewController的更多信息
https://stackoverflow.com/questions/43783971
复制相似问题