关闭AvPlayerViewController ios

时间:2018-08-23 09:54:16

标签: ios avplayer avplayerviewcontroller

您好,我的应用程序中有avplayerViewController。我只是启动应用程序,然后单击开始播放按钮-这将启动avplayerviewcontroller。在这里,我只是拖动搜索栏,然后在内容开始播放之前缓冲内容。我只是关闭了playerViewcontroller。几秒钟后,内容开始播放(即将播放音频)。这是一个非常严重的问题,请指导我如何解决此问题。到目前为止,当我关闭播放器时,我正在执行以下操作。

@try{

        [self.player replaceCurrentItemWithPlayerItem:nil];
        [self.player setRate:0.0];
        [self.player seekToTime:CMTimeMake(0, 1)];
        [self.player pause];


        dispatch_async(dispatch_get_main_queue(), ^{
            [self.contentOverlayView sendSubviewToBack:self->playerActivityIndicator];
            [self->playerActivityIndicator stopAnimating];
        });
        // [[self.player currentItem] removeObserver:self forKeyPath:@"status"];
        [[self.player currentItem] removeObserver:self forKeyPath:@"playbackBufferEmpty"];

        [self.player removeTimeObserver:self->playerPeriodicTimeObserver];


    }@catch(id anException){
        //do nothing, obviously it wasn't attached because an exception was thrown
        NSLog(@"No observer for a player in hide placeholder");
    }

0 个答案:

没有答案