我使用MPMoviePlayerViewController
来播放来自服务器的视频流,其他一切工作都很流畅。我的问题是,当我播放视频时,它会自动播放,如果没有可用的可播放内容,将自动进入暂停状态,并且在获取内容后不会播放。MPMoviePlayer在流式传输时自动暂停
movieController = [[MPMoviePlayerViewController alloc] init];
movieController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[movieController.moviePlayer setContentURL:mediaURL];
[movieController.moviePlayer prepareToPlay];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[movieController.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[movieController.moviePlayer setFullscreen:YES];
[movieController.moviePlayer setShouldAutoplay:YES];
[movieController.moviePlayer play];
[self presentMoviePlayerViewControllerAnimated:movieController];
这是我的代码,用于播放从mediaURL
给出的网址的视频。我试图添加MPMoviePlayerPlaybackStateDidChangeNotification
检查状态更改为MPMoviePlaybackStatePaused
,它也工作正常。还检查MPMovieLoadState
与MPMovieLoadStatePlaythroughOK
使用MPMoviePlayerLoadStateDidChangeNotification
问题是,自动暂停后没有得到MPMovieLoadStatePlaythroughOK
。 This link
也有什么办法可以得到暂停按钮水龙头以外的MPMoviePlayerPlaybackStateDidChangeNotification
,因为通知也因其他原因被解雇。