0

I am developing a video player using the OSMF library. I have the problem that I sometimes lose the connection to the server. So I set up an object that watches the connection to the server and in case of connection lost it tries a limited number of times to reconnect before giving up. Everything works just fine except for the message that I get on the debugger version of the player which states:

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound

I do have an object that inherits from HTTPStreamingNetLoader and overides the processFinishLoading method, gets the netStream and listens to the net status events. Like this:

override protected function processFinishLoading(loadTrait:NetStreamLoadTrait):void
   {    
            netStream = loadTrait.netStream as HTTPNetStream;
            netStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
    ...
    }

But I still get the error. The onNetStatus method gets events like NETSTREAM_BUFFER_EMPTY, NETSTREAM_BUFFER_FULL or NETSTREAM_PLAY_START but not NETSTREAM_PLAY_STREAMNOTFOUND Any ideas how to handle this? Thanks.

Julio Garcia
  • 1,904
  • 16
  • 26

3 Answers3

4

You can get it from a mediaElement

mediaElement.addEventListener(MediaElementEvent.TRAIT_ADD, onTraitAdd);

then,

private function onTraitAdd(event:MediaElementEvent):void
{
  trace(" [add]", event.toString()); 
  if (event.traitType == MediaTraitType.LOAD)
  {

    if (mediaElement.hasTrait(MediaTraitType.LOAD))
    {
      netStreamLoadTrait = mediaElement.getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
      netStreamLoadTrait.addEventListener(LoadEvent.LOAD_STATE_CHANGE, onLoaded);

    }
  }
}


private function onLoaded(event:LoadEvent):void
{
  netStream = netStreamLoadTrait.netStream;
  netStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
}
Flasher
  • 41
  • 1
2

You can listen to MediaPlayer state changes:

mediaPlayer.addEventListener( MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, onMediaPlayerStateChange, false, 0, true);

...

private function onMediaPlayerStateChange(e:MediaPlayerStateChangeEvent):void
{
    _mediaState = e.state;      

    switch (_mediaState) 
    {
        case MediaPlayerState.READY:                        
        break;

        case MediaPlayerState.BUFFERING:
        break;

        case MediaPlayerState.LOADING:
        break;

        case MediaPlayerState.PAUSED:
        break;  

        case MediaPlayerState.PLAYING:
        break;  

        case MediaPlayerState.PLAYBACK_ERROR:
        break;

        case MediaPlayerState.UNINITIALIZED:
        break;
    }
}
Marcelo Assis
  • 5,136
  • 3
  • 33
  • 54
0
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandle

public function netStatusHandler(e:NetStatusEvent):void{
  switch (e.info.code){
    case "NetStream.Seek.InvalidTime":
        trace('seek was to far')
      break;
    case "NetStream.Play.StreamNotFound":
        trace("Unable to locate video");
      break;
  }
} 
The_asMan
  • 6,364
  • 4
  • 23
  • 34
  • That is of course what I am doing and it doesn't work. The error is triggered without ever calling the netStatusHandler which otherwise receives other NetStatusEvents like the buffering events I mention before. – Julio Garcia Jul 13 '11 at 07:59
  • Then it is something with the stream service. – The_asMan Jul 14 '11 at 00:33