Error events you must handle in play flv video
来源:互联网 发布:c语言 取分隔符 编辑:程序博客网 时间:2024/05/21 14:41
用Video,NetConnection,NetStream类来加载并播放flv文件。在脚本中要处理相应的事件:
NetStatusEvent-当NetConnection对象执行connect()方法后会改变NetStatus;NetStream对象执行Play()方法时的出错处理也由它来监听。
SecurityErrorEvent-NetConnection对象执行connect()出错的监听器。
AsyncErrorEvent-NetStream对象执行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.
}
}
}
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.
}
}
}
- Error events you must handle in play flv video
- Play local Video(flv mainly) in ActionScript3.0
- configure: error: you must configure in a separate build directory
- configure: error: you must configure in a separate build directory
- configure: error: you must configure in a separate build directory
- configure: error: you must configure in a separate build directory
- Handle Error in VBA
- play video in Qt using GStreamer xvimagesink
- configure编译时提示:configure: error: you must configure in a separate build directory
- **Error**: You must have `libtool' installed
- **Error**: You must have `libtool' installed
- wamp 中安装cakephp Fatal error: You must enable the intl extension to use CakePHP. in XXX
- ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supp
- mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must chang
- mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must change
- How to play video in cocos2dx with DirectShow
- How to play video with AVPlayerViewController (AVKit) in Swift
- Play Framework 错误信息显示 (error message display In play framework)
- linux用企鹅做标志的原因
- 数学:确定性的丧失
- 读书笔记--异常处理(3)
- 胃病面面观
- 函数对象的使用
- Error events you must handle in play flv video
- 数学 美 爱情
- 四电压比较器LM339的几个典型应用例子
- DOS用C语言下对文件目录的遍历
- 修改漫画
- Java6 JDK的安装
- 俄罗斯方块程序的另类算法
- C编写Windows服务程序详细介绍
- CRC校验8/16/32全搞定