ios avplayer播放完畢監聽
阿新 • • 發佈:2018-11-10
//播放監聽,可以監聽到播放完畢,每秒處發一次,從播放後的第一秒觸發,不是一播放就出發 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