1

我将AVPlayer一个图层设置为我的视图,当我呈现一个时,UIViewController我通过将速率设置为 0 来暂停视频,并且在视图中将出现我将速率设置回 1。

我也有一个通知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];
4

0 回答 0