Play Audio in Background on iOS

Scott Kidder kidder.scott at gmail.com
Mon Nov 25 13:19:44 PST 2013


Hi all,

I'm interested in writing an iOS application that can play audio received
over RTP.  I began with the excellent iOS tutorials, and have succeeded in
playing streaming audio with great results.

I'd like to play audio in the background, just as you would have when
playing music with the iPod application or other streaming music apps
(Spotify, Pandora, etc).  What I've seen is that audio playback always
stops as soon as the home button is pressed (currently all testing is
occurring with iOS 6 in the XCode simulator).

Are there any suggestions for background playback on iOS with gstreamer?


Here's a little more background on the changes I made.  I tested with the
RTP audio source and the test audio source, getting the same result with
both.  I modified the Tutorial 2 application provided with the GStreamer
iOS SDK so that:

1) The Tutorial 2-info.plist file has a property for 'Required background
modes' equaling 'App plays audio'.

2) Modified the 'gstreamerInitialized' function to create an audio session
and set the category to 'AVAudioSessionCategoryPlayback'.  The session is
shutdown when the app exits.

-(void) gstreamerInitialized
{
    dispatch_async(dispatch_get_main_queue(), ^{
        play_button.enabled = TRUE;
        pause_button.enabled = TRUE;
        message_label.text = @"Ready";
    });

    NSError *activationError = nil;
    BOOL success = [[AVAudioSession sharedInstance] setActive: YES error:
&activationError];
    if (!success) { /* handle the error in activationError */ }

    NSError *setCategoryError = nil;
    success = [[AVAudioSession sharedInstance]
               setCategory: AVAudioSessionCategoryPlayback
               error: &setCategoryError];

    if (!success) { /* handle the error in setCategoryError */ }
}


Thanks in advance,

--Scott Kidder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131125/b13fcca3/attachment.html>


More information about the gstreamer-devel mailing list