Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer class events

Are there any delegate methods in AVPlayer class? I need to handle interruptions such as phone call etc. AVAudioPlayer supports. If AVPlayer doesn't support it, how to stream audio with AVAudioPlayer?

like image 924
Timur Mustafaev Avatar asked Dec 16 '22 10:12

Timur Mustafaev


1 Answers

AVPlayer doesn't have the methods you want but you can use AVAudioSession object instead

1) Select AVAudioSession object (for example [AVAudioSession sharedInstance])
2) Set it active by calling setActive:error: method
3) Set its delegate (class implementing AVAudioSessionDelegate protocol)
4) Implement delegate's methods such as

-(void)beginInterruption;
-(void)endInterruptionWithFlags:(NSUInteger)flags;
-(void)endInterruption;
like image 122
Eldar Markov Avatar answered Dec 30 '22 02:12

Eldar Markov