Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How to check the end of an audio
- AVAsset *asset = [AVURLAsset URLAssetWithURL:your-url options:nil];
- AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset];
- self.player = [AVPlayer playerWithPlayerItem:anItem];
- __weak typeof(self) wself = self;
- CMTime interval = CMTimeMake(1, 1);
- id observer = [self.soundPlayer addPeriodicTimeObserverForInterval:interval queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
- // controlla la fine dell'audio
- CMTime duration = CMTimeConvertScale(wself.player.currentItem.duration, wself.player.currentTime.timescale, kCMTimeRoundingMethod_Default);
- if (CMTIME_COMPARE_INLINE(duration, ==, wself.player.currentTime)) {
- // TODO: your code here
- }
- }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement