相关疑难解决方法(0)

AVPlayerItem replaceCurrentItemWithPlayerItem阻塞

首先是关于应用程序的一些背景信息......
- 有很多涉及视频播放器的大量UI操作(主要是滚动)
- 视频是动态的,并根据我们当前的页面进行更改.
- 因此视频必须是动态的并且不断变化,并且UI需要响应

我最初使用a 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]; …
Run Code Online (Sandbox Code Playgroud)

iphone mpmovieplayercontroller ipad ios avplayer

28
推荐指数
1
解决办法
6840
查看次数

标签 统计

avplayer ×1

ios ×1

ipad ×1

iphone ×1

mpmovieplayercontroller ×1