ios avplayer播放完毕监听

//播放监听,可以监听到播放完毕,每秒处发一次,从播放后的第一秒触发,不是一播放就出发
        WeakObj(self)
        WeakObj(_voicePlayer)
        self.listenNer = [_voicePlayer addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(1, NSEC_PER_SEC) queue:NULL usingBlock:^(CMTime time) {
            //进度 当前时间/总时间
            CGFloat progress = CMTimeGetSeconds(_voicePlayerWeak.currentItem.currentTime) / CMTimeGetSeconds(_voicePlayerWeak.currentItem.duration);
            if (progress == 1.0f) {
                //播放百分比为1表示已经播放完毕
                //接着播放下一条录音
                [selfWeak playWithNext];
            }
        }];

更多问题,加QQ群讨论:565191947

猜你喜欢

转载自blog.csdn.net/a787188834/article/details/83928696