0

I'm going insane with one issue when trying to stream audio from a radio service. I get it to run in the background fine, setting the required background mode in my .plist file.

However, as soon as the audio is interrupted (or if i exit the application before the stream has successfully started) my application (i presume) is supended, as it no longer gives me feedback on e.g a change in connection.

I'd like to accomplish this, so that i can manage stream quality etc even when the application is in the background.

Anyone have any tips for me?

Gratefully David

David
  • 145
  • 3
  • 9
  • Have you registered to receive both remote control events and the AVPlayer notifications relevant to your needs? – Mark Willsher May 17 '12 at 18:03
  • I've registered to start listening for remote control notifications. Which AVPlayer notifications are you referring to? – David May 18 '12 at 13:09
  • I respond to AVPlayer changes by observing key value changes - is that what you mean? – David May 18 '12 at 13:10
  • Yes that is what I meant. Do I understand correctly then that you are able to manage stream quality as you desire in the background without problem - except when entering the background before streaming starts or if the audio is interrupted by eg a phone call? Also are you using BeginBackgroundTaskWithExpirationHandler? – Mark Willsher May 21 '12 at 17:50
  • Try this one, might work http://stackoverflow.com/questions/4771105/how-do-i-get-my-avplayer-to-play-while-app-is-in-background/5253254#5253254 – Patrick R Jun 14 '12 at 12:51
  • Thanks for your link @PatrickR I've been on this over and over, and i cannot for the life of me understand what the solution might be. Here's the scenario: When. with application in foreground, initiating [AVAudio play] and letting the audio actually begin playing everything works fine. If i move to background mode (even with background tasks) before the audio has actually started playing the playback never initiates. Anyone got this also? – David Aug 17 '12 at 17:19
  • @MarkWillsher yes, you're understanding me correctly. And yes, i'm using BeginBackgroundTaskWithExpirationHandler. I get NSLog() messages doing that, but the Audio never starts playing even though the isLikelyToPlay gets called via observeValueForKeyPath. – David Aug 17 '12 at 17:23
  • @David If you mean, you want to start the player in the background task-bar, like you can with the "music" app. Then it cant be done with AVPlayer. Altho, If you use the other audio-player(cant remember the name right now, sorry) you can do it with that instead. – Patrick R Aug 21 '12 at 08:08
  • @PatrickR do you mean AVAudioPlayer? I've also looked in to the AudioStreamer class found at https://github.com/mattgallagher/AudioStreamer/tree/master/Classes That works well, but i guess i need to take a closer look on Audio Queue Services to figure out how to re-establish a stream if the connection breaks momentarily. Any tips on where i can find info on this? Thanks! – David Aug 22 '12 at 09:04
  • @David actually no, unfortunately.. i have the same problem, when the connection times out, breaks or something else, that makes the player stop.. I can't seem to get it started again if the connection breaks. But if you find a solution, please share :) – Patrick R Aug 22 '12 at 13:14
  • 1
    @PatrickR I'll make sure to post the solution when i have it :-) – David Aug 23 '12 at 14:05

0 Answers0