Detect connection error when loading flv with VideoDisplay : VideoDisplay « Graphics « Flex






Detect connection error when loading flv with VideoDisplay

Detect connection error when loading flv with VideoDisplay
   

<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="Test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        initialize="init();">

    <mx:Script>
        
            import mx.controls.VideoDisplay;
            import mx.controls.Alert;
            import mx.events.VideoEvent;

            private var videoDisplay:VideoDisplay;

            private function init():void {
                videoDisplay = new VideoDisplay();
                videoDisplay.addEventListener(VideoEvent.STATE_CHANGE,onError);
                videoDisplay.source = "http://server.com/a.flv";
                addChild(videoDisplay);
            }

            private function onError(evt:VideoEvent):void {
                switch (evt.state) {
                    case VideoEvent.CONNECTION_ERROR:
                        evt.currentTarget.visible = false;
                        Alert.show(evt.currentTarget.source, "Failed to connect to video");
                        break;
                }
            }
      
    </mx:Script>

</mx:Application>

   
    
    
  








Related examples in the same category

1.Look up VideoDisplay's metadata cuePoints and compare to current cue point object
2.Listen for a Flash Video's cue points with VideoDisplayListen for a Flash Video's cue points with VideoDisplay
3.Use Button to control VideoDisplayUse Button to control VideoDisplay
4.Ready, rewind, playheadUpdate, close, complete and progress actions for VideoDisplayReady, rewind, playheadUpdate, close, complete and progress actions for VideoDisplay
5.autoPlay, autoRewind for VideoDisplayautoPlay, autoRewind for VideoDisplay
6.Detecting a connection error when loading an FLV with the VideoDisplay controlDetecting a connection error when loading an FLV with the VideoDisplay control
7.Use a VideoDisplay controlUse a VideoDisplay control
8.Set cue points for the VideoDisplay control by using the cuePointManager property.Set cue points for the VideoDisplay control by using the cuePointManager property.
9.Use VideoDisplay.attachCamera() method to display a video stream from a camera
10.Use VideoDisplay control to import a media stream from Macromedia Flash Media Server 2 from Adobe
11.A VideoDisplay control
12.When the playhead of the VideoDisplay control reaches a cue point, it dispatches a cuePoint event
13.VideoDisplay CuePoint Manager
14.VideoDisplay Camera
15.VideoDisplay FMSVideoDisplay FMS
16.Load video with Remote Data ProvidersLoad video with Remote Data Providers
17.Play video with VideoPlayPlay video with VideoPlay
18.Play video from a URLPlay video from a URL
19.Create a Video DisplayCreate a Video Display
20.Complete and mediaPlayerStateChange events dispatched by the VideoPlayer controlComplete and mediaPlayerStateChange events dispatched by the VideoPlayer control
21.Show the user of the DynamicStreamingVideoSource objectShow the user of the DynamicStreamingVideoSource object
22.Dispatch a cuePoint eventDispatch a cuePoint event
23.CuePointEvent DemoCuePointEvent Demo
24.Use the pause() and play() to pause or play an FLV fileUse the pause() and play() to pause or play an FLV file