0
我試圖從MPMoviePlayerViewController
切換到AVPlayer
在我的實現視頻播放看起來類似這種移動從MPMoviePlayerViewController到AVPlayer和流M3U8
NSURL *movieURL = [NSURL URLWithString:@"http://example.com/somefile.m3u8"];
movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
movieController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentMoviePlayerViewControllerAnimated:movieController];
[movieController.moviePlayer play];
我AVPlayer
版本起一切,但所需的m3u8
流。它設法找到該文件,AVPlayerViewController
顯示正確的文件持續時間,但掛起一個活動指示,並且從未真正開始播放。
NSURLComponents *comp = [NSURLComponents componentsWithString:url.absoluteString];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:comp.URL options:nil];
AVAssetResourceLoader *loader = asset.resourceLoader;
[loader setDelegate:self queue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)];
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithAsset:asset];
self.player = [AVPlayer playerWithPlayerItem:playerItem];
我有狀態的觀察,當AVPlayer
的狀態是ReadyToPlay
它最終播放。 我無法想象AVPlayer
可以播放所有的東西MPMoviePlayerController
那麼如何才能正確執行AVPlayer
版本才能使這個工作。