I am working with iOS5.
I am working on HTTPLivestream project .Here i am using MPMovieplayer ,my problem is when application goes to background there is no audio . i am changing the plist in background mode is audio.But there is no result please help me .
AppDel
- (void)applicationDidEnterBackground:(UIApplication *)application {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
UIApplication *app = [UIApplication sharedApplication];
backgroundTask = [app beginBackgroundTaskWithExpirationHandler:^{
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
});
}
RadioControlView
NSString *path =[[NSString alloc] initWithString:@"http://*******/alayam/alayam/playlist.m3u8"];
audioUrl=[NSURL URLWithString:path];
appDelegate.player = [[MPMoviePlayerController alloc] initWithContentURL:audioUrl];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(loadStateDidChange:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:appDelegate.player];
if ([appDelegate.player respondsToSelector:@selector(loadState)])
{
[appDelegate.player setControlStyle:MPMovieControlModeVolumeOnly];
[appDelegate.player setFullscreen:YES];
[appDelegate.player prepareToPlay];
}
- (void)loadStateDidChange:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:appDelegate.player];
}
Thanks in Advance
If you are testing on simulator, then it’s doesn’t work on simulator, please use device. If you are using device and audio is not playing in background, then can you please email me your complete source code at khalid0491@gmail.com. I have also done in my Application.
My code is given below.
and in plist i made an array named “Required background mode” and insert an item in array name, “App Plays Audio”.