【发布时间】:2013-01-12 19:40:44
【问题描述】:
首先是关于应用程序的一些背景...
- 有很多繁重的 UI 操作涉及视频播放器(主要是滚动)
- 视频是动态的,会根据我们当前的页面而变化。
- 所以视频必须是动态的并不断变化,而且用户界面也需要响应
我最初使用的是MPMoviePlayerController,但后来由于某些要求,我不得不退回到 AVPlayer
我为AVPlayer 制作了自己的包装器。
要更改 videoPlayer 中的内容,这就是 AVPlayer-wrapper 类中的方法
/**We need to change the whole playerItem each time we wish to change a video url */
-(void)initializePlayerWithUrl:(NSURL *)url
{
AVPlayerItem *tempItem = [AVPlayerItem playerItemWithURL:url];
[tempItem addObserver:self forKeyPath:@"status"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:nil];
[tempItem addObserver:self forKeyPath:@"playbackBufferEmpty"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:nil];
//Not sure if this should be stopped or paused under the ideal circumstances
//These will be changed to custom enums later
[self setPlaybackState:MPMoviePlaybackStateStopped];
[self setLoadState:MPMovieLoadStateUnknown];
[self.videoPlayer replaceCurrentItemWithPlayerItem:tempItem];
//This is required only if we wish to pause the video immediately as we change the url
//[self.videoPlayer pause];
}
当然现在一切正常......除了......
[self.videoPlayer replaceCurrentItemWithPlayerItem:tempItem];
似乎在几分之一秒内阻塞了 UI,并且在滚动过程中,这使得 UI 非常无响应且丑陋,而且此操作无法在后台执行
是否有任何解决方法或解决方法?
【问题讨论】:
-
你找到解决办法了吗?
-
@AdrianDemetrescu - 不......必须恢复到 mpmovieplayer
-
您尝试过这些建议了吗? stackoverflow.com/questions/7420176/…
-
我没有,如果它确实有效......你可以在这里发布修复
-
我也被这个困住了......有人吗?
标签: iphone ios ipad mpmovieplayercontroller avplayer