user3241709
user3241709

Reputation: 39

UIWebview radio stream plays in background?

I'm new into Apple developing but I need to make an easy Radio Streaming App. I've made everything and the app works correctly on my iPhone (with IOS 6) but it stops playing when I'm pushing home button (when the app goes into background mode). Is there any posibility to make the Webview work in background?

Upvotes: 0

Views: 563

Answers (2)

brussell
brussell

Reputation: 111

You will need to go to your Project, then the Capabilities tab, then turn on the Background Modes and toggle on the one for background audio. You will also need to set your audio session to the playback category

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:nil error:nil];

Upvotes: 2

Mika
Mika

Reputation: 5845

You need to use the AVAudioPlayer class.

NSURL *url = [NSURL URLWithString:@"http://puttheurlhere.com"];
NSData *data = [NSData dataWithContentsOfURL:url];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:nil];
[audioPlayer play];

Upvotes: 0

Related Questions