@runmad,我也用同樣的方式做,但我試圖打開本地video.here是我的代碼
{
// Initialize the movie player view controller with a video URL string
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
/*NSURL *url = [NSURL URLWithString:@"https://www.youtube.com/watch?v=qcI2_v7Vj2U"];
playerViewController.player = [AVPlayer playerWithURL:url];*/
// playerViewController.player = [AVPlayer playerWithURL: [ [filePath]URLForResource:@"Besan"
// withExtension:@"mp4"]];
NSLog(@"\nFile URL\n%@",videosURL);
AVPlayerItem* item=[[AVPlayerItem alloc]initWithURL:videosURL];
NSLog(@"\n\nAVPlayerItem\n%@",item);
playerViewController.player=[AVPlayer playerWithPlayerItem:item];
[playerViewController.player play];
[self presentViewController:playerViewController animated:YES completion:^{}];
}
我已經沒有AVPlayerItem
完成,但結果是一樣的(只有黑色屏幕完成,播放,前進,後退按鈕)。
比我用MPMoviePlayerController
嘗試,但它很快被駁回,不顯示視頻。 這裏的MPMoviePlayerController代碼,
{
MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc]initWithContentURL:videosURL];
[self presentMoviePlayerViewControllerAnimated:moviePlayerController];
[moviePlayerController.moviePlayer play];
}
不知道爲什麼你沒有調試的URL – onmyway133 2015-01-20 09:21:51