AVPlayer从其他viewcontroller返回时播放

时间:2015-08-31 17:12:32

标签: ios objective-c avplayer avplayerlayer

我在我的视图中设置了AVPlayer作为图层,当我提出UIViewController我通过将比率设置为0来暂停视频时,我会在视图中设置回复率一个。

我还在UIApplicationWillEnterForegroundNotificationUIApplicationDidEnterBackgroundNotification发出了相同的通知(在背景上暂停,在前景播放)......

当我呈现VC然后再回来时,我无法让视频继续播放,但是当我去背景并回来时 - 它播放得很好..

不确定我错过了什么..

这就是我设置播放器的方式

self.player = [[AVPlayer alloc]initWithURL:videoUrl];
    self.player.allowsExternalPlayback = NO;

    self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
    self.playerLayer.frame = CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height);
    self.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
    self.playerLayer.player.muted = YES;
    [self.view.layer insertSublayer:self.playerLayer atIndex:0];

0 个答案:

没有答案