# Play stream in IOS app (Check stream before playing)

**URL:** <https://community.wowza.com/t/play-stream-in-ios-app-check-stream-before-playing/39993>\
**Category:** Wowza Streaming Engine\
**Created:** [February 9, 2014, 4:27am UTC](https://community.wowza.com/t/play-stream-in-ios-app-check-stream-before-playing/39993 "2014-02-09T04:27:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Perez](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@Richard\_Perez](https://community.wowza.com/u/Richard_Perez)\
**Post date:** [February 9, 2014, 4:27am UTC](https://community.wowza.com/t/play-stream-in-ios-app-check-stream-before-playing/39993/1 "2014-02-09T04:27:01Z")

</div>

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 :

```auto
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

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [February 12, 2014, 9:14am UTC](https://community.wowza.com/t/play-stream-in-ios-app-check-stream-before-playing/39993/2 "2014-02-12T09:14:03Z")

</div>

One idea would be to create an [http provider](https://www.wowza.com/docs/http-providers)(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.
