1

I'm using MPMoviePlayerViewController to stream an audio from the URL "http://ios-audio.q-music.be/audio.m3u8". Its playing well. But when I click "Home" button, the app goes into background and stops streaming. When I start the app again, it starts streaming again.

How can I make my app stream the audio using MPMoviePlayerController when the app goes to background. Or do I've to use other frameworks?

Satyam
  • 15,493
  • 31
  • 131
  • 244
  • Did you add the `Required background modes` audio to your app's info.plist? Also I'm not sure that MPMoviewPlayer will support background playing. – rckoenes Aug 05 '11 at 13:21
  • Yes, I added the the necessary modes in Info.plist file. If MPMoviePlayerViewController don't support background playing, which framework/class supports it. Can u show me some example please? – Satyam Aug 05 '11 at 13:33
  • Make sure you fiddle around a little with your current App AudioSession. – Till Aug 05 '11 at 13:37
  • Till, what audio session should I set? – Satyam Aug 05 '11 at 13:38

2 Answers2

0

Well I use https://github.com/mattgallagher/AudioStreamer for streaming audio, It will work in background.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • I tried this code as well. But its not running in background. Did u make any changes to existing code? Because it don't have background modes in info.plist file..... – Satyam Aug 05 '11 at 13:41
  • No just added the `Required background modes` key and set it to `audio` – rckoenes Aug 05 '11 at 13:47
  • I did that and still its not playing the mp3 URL that is mentioned in the code. And more over, my URL is not supported by that code at all. – Satyam Aug 05 '11 at 14:01
  • Well you will need to parse `m3u8` file and select te correct stream, then just play that. The `m3u8` is just playlist file, there are multiple stream (links to other `m3u8` files) in the file. Finallly there is just an `aac` file there: `audio_low_70588.aac` – rckoenes Aug 05 '11 at 14:04
  • Can u share the AudioStreamer code that plays audio in background also. I tried again and again and its not playing the audio in background. – Satyam Aug 05 '11 at 14:11
  • Just download this https://github.com/DigitalDJ/AudioStreamer/ and run the example project. It will play in the background. – rckoenes Aug 05 '11 at 14:38
0

http://digitaldj.net/2010/08/25/ios4-background-audio-revisited/ points to a fork of Matt Gallagher's original AudioStreamer code at http://github.com/DigitalDJ/AudioStreamer, which I can verify does support background audio. That said the original AudioStreamer has been updated this year so I'd imagine it also has implemented background support by now.

Certainly using MPMoviePlayerController to do background audio would be interesting since it presumably opens up the opportunity to support AirPlay directly in an audio streamer application.

flaneur
  • 66
  • 3