10

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 :)

Jonas
  • 121,568
  • 97
  • 310
  • 388
Gamer
  • 369
  • 3
  • 11

1 Answers1

9

You are entirely correct in ignoring those internal assert messages. There is nothing you can do about them.

Till
  • 27,559
  • 13
  • 88
  • 122
  • 1
    Thank you Till. I was also confused about these logging messages (`...Took background task assertion (n) for playback stall`) in a big fat video playing app you might have heard of... – Kai Huppmann Apr 22 '13 at 08:31
  • the streaming in my app stops a lot because of this assertion!!, what can i do? – Mutawe Sep 15 '13 at 08:12
  • @Mutawe you are getting it the wrong way around. That assertion is happening a lot because your streaming runs out of content - check the network connectivity and the stream encoding. – Till Sep 16 '13 at 09:25
  • @Till is there any event callback about these messages ? – onmyway133 Jul 09 '14 at 08:45