Tuesday, April 22, 2014

iOS Playing Streaming files

Almost urgently had to look into iOS feature for playing streaming file and running app in background and play the file. Below is some notes from it.

 Making the app to run in background to play the audio.

At a minimum
- UIBackgroundMode should be set to "App plays audio or streams audio/video using AirPlay"
- For basic playback set the audiosessioncategory to AVAudioSessionCategoryPlayback

Below code can be present in the app delegate didFinishLaunchingWithOptions method so that app gets the cycles to execute and play the music while in background.

AVAudioSession* audio = [[AVAudioSession alloc] init];
    [audio setCategory: AVAudioSessionCategoryPlayback error: nil];

    [audio setActive: YES error: nil];

A more hands on needs to be done for this part. In next blogs indeed.

This is very helpful link
http://www.sagorin.org/ios-playing-audio-in-background-audio/

No comments:

Post a Comment