Discussion Forums  >  Uncategorized

Replies: 1    Views: 272

ThomasSechak
Aspiring developer
Profile
Posts: 59
Reg: Jul 10, 2011
Charlottsville
10,690
08/13/11 07:47 AM (14 years ago)

Begin and End Interuption for Audio

Hi I have another question. My new audio app that I am making properly stops when a phone call comes in after I added the code mentioned in the post with the subject Audio Playback Even When Auto-Lock Turns On Adding the code on that page makes it work with screen lock and works with multitasking as well as pausing for a phone call. Now I am wondering how to resume playback when a phone call has ended. As far as I understand it should be possible. I experimented with the following but it did not appear to do anything. How can I make this work. Do I need to add code in a different place, or perhaps what is below is implemented wrong. Here is what I did. The first part was already in the BT_Screen_Audio.m file and I added the second part called //audio interruption started. Simply by coping and pasting the first part and making small changes. But this was simply a guess on my part, that failed. //audio interuption started -(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player{ [BT_debugger showIt:self:[NSString stringWithFormat:@audioPlayerBeginInterruption%@, @]]; //flag as not-playing [self setAudioIsPlaying:FALSE]; } //audio interuption Ended -(void)audioPlayerEndInterruption:(AVAudioPlayer *)player{ [BT_debugger showIt:self:[NSString stringWithFormat:@audioPlayerEndInterruption%@, @]]; //flag as playing [self setAudioIsPlaying:TRUE]; } Thanks
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/14/11 12:55 AM (14 years ago)
Not sure, it's been awhile. But, I think the audioPlayerEndInteruption method is fired when the call is done. This means you'll want to put a line in that method to re-start the player if it's stopped.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.