Wowza Community

Play stream in IOS app (Check stream before playing)

Hello,

I’m trying to secure the playing a wowza stream on my Ios apps.

I succeed in playing the stream but the problem is that is don’t know how to check if the stream is playing before launching it in my apps. Because if the server is down or the stream is not published there is no error message, the player just stay black.

I would like to display an error message or to stop the app if the server is down or if the stream is not published.

I tried to use the notifications :

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:streamPlayer];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:streamPlayer];

But none of these one are are fired if the stream is not available.

Here is my current code :

NSURL *streamURL = [NSURL URLWithString:@"http://XXX.com:1935/XX/XXX/playlist.m3u8"];
    streamPlayer = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];
    streamPlayer.shouldAutoplay = YES;
    streamPlayer.controlStyle = MPMovieControlStyleNone;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:streamPlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:streamPlayer];
    
    CGRect streamPlayerFrame = CGRectMake(0, 65, 320, 180);
    [streamPlayer.view setFrame: streamPlayerFrame];
    [streamPlayer play];

Somebody knows how to do that?

Richard

One idea would be to create an http provider (on the Wowza side) that you could query from your iOS app that would return true/false if the stream is up. Then you could handle the event as described.