Error events you must handle in play FLV video

Source: Internet
Author: User

Use the video, netconnection, and netstream classes to load and play FLV files. Process the corresponding event in the script:

Netstatusevent-when the netconnection object executes the connect () method, netstatus is changed. When the netstream object executes the play () method, error handling is also monitored by it.

The securityerrorevent-netconnection object executes the listener for a connect () error.

Listener for an error occurred when the asyncerrorevent-netstream object executes play.

Demo:

Package {
Import flash. display. Sprite;
Import flash. Events .*;
Import flash. Media. video;
Import flash.net. netconnection;
Import flash.net. netstream;

Public class netstatuseventexample extends sprite {
Private var videourl: String = "video. FLV ";
Private var connection: netconnection;
Private var stream: netstream;

Public Function netstatuseventexample (){
Connection = new netconnection ();
Connection. addeventlistener (netstatusevent. net_status, netstatushandler );
Connection. addeventlistener (securityerrorevent. security_error, securityerrorhandler );
Connection. Connect (null );
}

Private function netstatushandler (Event: netstatusevent): void {
Switch (event.info. Code ){
Case "netconnection. Connect. Success ":
Connectstream ();
Break;
Case "netstream. Play. streamnotfound ":
Trace ("unable to locate video:" + videourl );
Break;
}
}

Private function connectstream (): void {
VaR stream: netstream = new netstream (connection );
Stream. addeventlistener (netstatusevent. net_status, netstatushandler );
Stream. addeventlistener (asyncerrorevent. async_error, asyncerrorhandler );
VaR video: Video = new video ();
Video. attachnetstream (Stream );
Stream. Play (videourl );
Addchild (video );
}

Private function securityerrorhandler (Event: securityerrorevent): void {
Trace ("securityerrorhandler:" + Event );
}

Private function asyncerrorhandler (Event: asyncerrorevent): void {
// Ignore asyncerrorevent events.
}

}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.