I am developing an online radio app for iOS6 devices. Ive looked for various wrappers to achieve this task. AVPlayer, MPMoviePlayerController etc.
I tried using AVPlayer as it sounds more correct to use it for my purpose as it is audio only application. But soon I came across this problem : Here
Therefore I switched to MPMoviePlayerController and this is what Im trying to do :
pPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://launch.fusionradio.fm:8004"]];
pPlayer.movieSourceType = MPMovieSourceTypeStreaming;
pPlayer.view.hidden = YES;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[pPlayer prepareToPlay];
[pPlayer play];
pPlayer.shouldAutoplay = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(StreamStateChanged) name:MPMoviePlayerLoadStateDidChangeNotification object:pPlayer];
In my StreamStateChanged method Im doing :
NSLog(@"Trying to replay");
[pPlayer pause];
[pPlayer play];
pPlayer is MPMoviePlayer. Everything is fine except when there is an interrupt Console spits out the following :
Took background task assertion (1) for playback stall.
Ending background task assertion (1) for playback stall.
The number after assertion keeps increasing. and then it recovers from it once the internet connection is stable.
My question is : Is this approach correct? Am I doing something wrong along the way? And Is it ok to ignore that assert message?.
P.S : Please suggest if there is a better approach for developing radio streaming app using different API as opposed to MPMoviePlayerController
Thank you :)
...Took background task assertion (n) for playback stall
) in a big fat video playing app you might have heard of... – Milzie