iPhone Sdk Listening for Background Audio
I have an app that plays background music using AVAudioPlayer. The app also has youtube videos in it. When the user taps on the youtube video, I need the background audio to turn off. When they have 开发者_如何学Pythoneither completed watching the video, I need the audio to resume.
The youtube video is getting played by embedding the video into an UIWebView. View Eample Here
I have tried using the delegate methods for AVAudioPlayer -
- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withFlags:(NSUInteger)flags
- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
However, audioPlayerEndInterruption
never winds up getting called.
So ultimately, I need a way to stop the music when the video is launched and resumed once the user is done with the video.
Method that could work but am not sure how to implement:
-Have a timer that checks for any audio playing on the device, check to see if it is not the audio player(would be the youtube player), then stop the background audio
If anyone has any suggestions, I would really appreciate them
精彩评论