- 浏览: 11645 次
最新评论
Handling metadata and cue points in Flash video(AsyncErrorEvent text=Error #2095 flash.net.NetStream)
- 博客分类:
- 技术杂绘
Handling metadata and cue points in Flash video(AsyncErrorEvent text=Error #2095 flash.net.NetStream)
2011年04月13日
This Quick Start article illustrates several techniques for handling the DE>onMetaDataDE> and DE>onCuePointDE> callback methods when using the NetConnection and NetStream classes to load Flash videos (FLVs). You'll discover how you can use the DE>asyncErrorDE> event (DE>AsyncErrorEvent.ASYNC_ERRORDE>) or DE>clientDE> property in the NetStream class to handle or ignore the meta data or cue points. The next sections describe the most popular and useful ways to use the DE>asyncErrorDE> and DE>clientDE> property when working with loading videos. There are many cases where you may prefer to create your own custom video player to play videos instead of using an existing component. For example, you may be trying to build a certain feature into your custom video player, or perhaps you're trying to make a video player with a very small file size. When building your own code, it is important to understand how the DE>onMetaDataDE> and DE>onCuePointDE> event handlers are used so you can handle them accordingly. The following example creates a new NetConnection, NetStream, and Video object to dynamically load an FLV file and display it in an SWF file. Since the specified FLV contains metadata and three cue points and there are no handlers defined for the DE>onMetaDataDE> and DE>onCuePointDE> event handlers, the DE>asyncErrorDE> is dispatched and informs you that the NetStream class was unable to invoke the callback DE>onMetaDataDE> and DE>onCuePointDE>: DE>var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.play("http://www.helpexamples.com/flash/video/c uepoints.flv"); var myVideo:Video = new Video(); myVideo.attachNetStream(ns); addChild(myVideo); DE> Result
The previous example loads a Flash video file and begins video playback. Once the video's metadata or cue points are encountered an DE>asyncErrorDE> is dispatched. If you're running this code in the Flash authoring environment, you'll see that four errors are displayed in the Output panel with error messages similar to the following: DE>Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onMetaData. error=ReferenceError: Error #1069: Property onMetaData not found on flash.net.NetStream and there is no default value. at asyncErrorExample_fla::MainTimeline/asyncErrorExam ple_fla::frame1() Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint. error=ReferenceError: Error #1069: Property onCuePoint not found on flash.net.NetStream and there is no default value. at asyncErrorExample_fla::MainTimeline/asyncErrorExam ple_fla::frame1() Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint. error=ReferenceError: Error #1069: Property onCuePoint not found on flash.net.NetStream and there is no default value. at asyncErrorExample_fla::MainTimeline/asyncErrorExam ple_fla::frame1() Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint. error=ReferenceError: Error #1069: Property onCuePoint not found on flash.net.NetStream and there is no default value. at asyncErrorExample_fla::MainTimeline/asyncErrorExam ple_fla::frame1() DE>
If you were looking at this SWF online in a web browser, you'd see the following errors instead: To prevent these errors, you have two primary solutions: Add an event listener for the DE>asyncErrorDE> event.
Set a value for the NetStream object's DE>clientDE> property.
To get the source files for this example, including Flash Professional CS5 versions of the files, download example01.zip at the top of this page. One of the easiest ways to handle the DE>asyncErrorDE> event dispatched by the NetStream object is to listen for the event using the DE>addEventListener()DE> method. This allows you to either handle or ignore the event. Example
The following example loads an FLV and traces the DE>asyncErrorDE> event's DE>textDE> property whenever the DE>asyncErrorDE> is dispatched: DE>var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); ns.play("http://www.helpexamples.com/flash/video/c uepoints.flv"); var myVideo:Video = new Video(); myVideo.attachNetStream(ns); addChild(myVideo); function asyncErrorHandler(event:AsyncErrorEvent):void { trace(event.text); } DE>
The second way to handle the DE>asyncErrorDE> event is to use the DE>clientDE> property of the NetStream class. The DE>clientDE> property specifies the object on which callback methods are invoked. The default object is the NetStream object being created. If you set the DE>clientDE> property to another object, callback methods will be invoked on that other object. Example
The following example creates a NetStream object and sets its DE>clientDE> property to an empty object, which prevents the DE>asyncErrorDE> from being dispatched: DE>var customClient:Object = new Object(); customClient.onMetaData = metaDataHandler; var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.client = customClient; ns.play("http://www.helpexamples.com/flash/video/c uepoints.flv"); var myVideo:Video = new Video(); myVideo.attachNetStream(ns); addChild(myVideo); function metaDataHandler(infoObject:Object):void { myVideo.width = infoObject.width; myVideo.height = infoObject.height; } DE>
The previous example defines a handler method for the DE>onMetaDataDE> handler which resizes the Video object on the Stage to match the dimensions of the FLV document, as reported by the metadata. Tip: You can also use the following shorthand notation for creating an object and specifying a handler:
DE>var customClient:Object = {onMetaData:metaDataHandler};DE> This examples will display like this: To get the source files for this example, including Flash Professional CS5 versions of the files, download example03.zip at the top of this page. Note: All of the following examples will display just like the example shown above. However some of the following examples will show additional trace information in the Flash concole window when they are run within the Flash CS3 authoring tool. One of the easiest ways to handle the DE>asyncErrorDE> event dispatched by the NetStream object is to listen for the event using the DE>addEventListener()DE> method. This allows you to either handle or ignore the event. Example
The following example sets the NetStream object's DE>clientDE> property to a custom class, CustomClient, which defines handlers for the callback methods: Note: The CustomClient class defines a handler for the DE>onMetaDataDE> callback handler. If a cue point was encountered and the DE>onCuePointDE> callback handler was called, an DE>asyncErrorDE> event would be dispatched saying "flash.net.NetStream was unable to invoke callback onCuePoint." To prevent this error, you would either need to define an DE>onCuePointDE> callback method in your CustomClient class, or define an event handler for the DE>asyncErrorDE> event. To get the source files for this example, including Flash Professional CS5 versions of the files, download example04.zip at the top of this page. DE>package { import flash.net.NetConnection; import flash.net.NetStream; public class CustomNetStream extends NetStream { public function CustomNetStream(nc:NetConnection) { super(nc); } public function onMetaData(infoObject:Object):void { trace("metadata"); } public function onCuePoint(infoObject:Object):void { trace("cue point"); } } } DE>
DE>package { import flash.net.NetConnection; import flash.net.NetStream; public class CustomNetStream extends NetStream { public var onMetaData:Function; public var onCuePoint:Function; public function CustomNetStream(nc:NetConnection) { onMetaData = metaDataHandler; onCuePoint = cuePointHandler; super(nc); } private function metaDataHandler(infoObject:Object):void { trace("metadata"); } private function cuePointHandler(infoObject:Object):void { trace("cue point"); } } DE>
Even with no handlers for the DE>onMetaDataDE> and DE>onCuePointDE> callback handlers, no errors are thrown since the DynamicCustomNetStream class is dynamic. If you want to define methods for the DE>onMetaDataDE> and DE>onCuePointDE> callback handlers, you could use the following code: DE>var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:DynamicCustomNetStream = new DynamicCustomNetStream(nc); ns.onMetaData = metaDataHandler; ns.onCuePoint = cuePointHandler; ns.play("http://www.helpexamples.com/flash/video/c uepoints.flv"); var vid:Video = new Video(); vid.attachNetStream(ns); addChild(vid); function metaDataHandler(infoObject:Object):void { trace("metadata"); } function cuePointHandler(infoObject:Object):void { trace("cue point"); } DE>
To get the source files for this example, including Flash Professional CS5 versions of the files, download example07.zip at the top of this page. For more information
For more information about this topic, see "Using the Adobe Flash CS3 Video Encoder". For more information about this topic, see the NetStream class in the ActionScript 3.0 Reference for the Adobe Flash Platform.
发表评论
-
宇龙酷派WINCE6.0 SDK配置方法
2012-01-20 09:24 821宇龙酷派WINCE6.0 SDK配置 ... -
Java EE 6 SDK+Eclipse JEE+Android ADT
2012-01-20 09:24 937Java EE 6 SDK+Eclipse JEE+Andro ... -
VC6.0下WMI编程需要先安装Platform SDK
2012-01-20 09:24 926VC6.0下WMI编程需要先安装Platform SDK 2 ... -
[转]Android开发环境搭建全程演示(jdk+eclipse+android sdk)
2012-01-20 09:24 632[转]Android开发环境搭建 ... -
倘若我能说出我的心声
2012-01-19 14:25 612倘若我能说出我的心声 2011年03月05日 [/b] ... -
高帝制礼作乐,周昌谏废太子
2012-01-19 14:25 635高帝制礼作乐,周昌谏废 ... -
第十四章 我是商鞅(上)
2012-01-19 14:24 634第十四章 我是商鞅( ... -
转载:全面介绍javascript异常处理(try…catch…finally window.onerror)
2012-01-17 04:14 602转载:全面介绍javascript异常处理(try…catch ... -
《JavaScript高级程序设计》学习笔记――错误处理与调试
2012-01-17 04:13 594《JavaScript高级程序设计》学习笔记――错误处理与调试 ... -
ecshop transport.js/run() error:undefined
2012-01-17 04:13 690ecshop transport.js/run() error ... -
Adobe荐文:处理Flash视频里的元数据和录像暗点
2012-01-17 04:13 873Adobe荐文:处理Flash视频 ... -
赞美别人的词语
2012-01-16 03:02 905赞美别人的词语 2009年11月29日 人物品格的词语∶ ... -
赞美女人的词语
2012-01-16 03:02 682赞美女人的词语 2011年05月02日 漂亮的叫美女, ... -
赞美女性的词语大全
2012-01-16 03:02 679赞美女性的词语大全 2010年07月18日 温柔、体贴 ... -
赞美女性的词语
2012-01-16 03:02 632赞美女性的词语 2010年05月21日 温 ...
相关推荐
Explore advanced .NET APIs and create a basic .NET core library with dynamic code generation and metadata inspection to be used by other libraries or client applications. This book starts with the ...
# centers in dubbo2.7 admin.registry.address=zookeeper://127.0.0.1:2181 admin.config-center=zookeeper://127.0.0.1:2181 admin.metadata-report.address=zookeeper://127.0.0.1:2181 admin.root.user.name=...
Alas, virtually all of these books are dedicated to .NET-based programming in high-level languages and rapid application development (RAD) environments. No doubt this is extremely important, and I am...
You will learn how to use metadata driven programming, creating custom events with payloads, adding parallel constructs to your applications, using strict data bound controls in ASP.Net, enabling ...
You'll gain a solid background in managed code and .NET constructs within the context of the 2015 release, so you can get acclimated quickly and get back to work. The new updates can actively ...
this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0]...
敏特 Heroku Web服务器,可通过API轻松铸造不可替代的令牌 配置示例: 区块链:以太坊 测试网:Rinkeby 合同:ERC1155 Opensea 元数据托管:通过Pinata的IPFS ...编辑在/metadata/mono_metadata.
var i={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},a={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",...
Error handling in ActionScript 3.0259 ActionScript 3.0 error-handling elements..260 Error-handling strategies...261 Working with the debugger version of Flash Player.261 Handling synchronous errors in...
admin.metadata-report.address=zookeeper://192.168.0.102:2181 为防止端口冲突我修改为了 9999 然后用户名,密码为root和root 命令行:cd进入该jar包所在的路径,下 命令行: java -jar dubbo-admin-server-0.1....
Conventions Used in This Book..............................................................................9 How to Contact Us............................................................................
/// /// 创建VLC播放器 /// /// <param name="libvlc_instance">VLC 全局变量 /// <param name="handle">VLC MediaPlayer需要绑定显示的窗体句柄 /// <returns></returns> public static libvlc_media_...
# The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use ...
metadata-extractor-2.4.0.rar metadata-extractor-2.4.0.rar 获取 图片 exif 信息 使用方法: File jpegFile = new File("c:\\newchangetime.jpg"); Metadata metadata = JpegMetadataReader.readMetadata(jpeg...
Get the in-depth architectural information you need about the hottest OOP language for Microsoft® .NET—now updated for final release code.Take a detailed look at the internal architecture of the ...
Free Spire.PDF for .NET 允许开发人员在 .NET( C#, VB.NET, ASP.NET, .NET Core) 程序中创建、读取、写入、编辑和操作 PDF 文档。 Free Spire.PDF for .NET 支持的功能十分全面,例如文档安全性设置(电子签名),...
### 2、使用Q_DECLARE_INTERFACE()宏 tell Qt's meta-object system about the interface.Export the plugin using the Q_PLUGIN_METADATA() macro. ### 3、QPluginLoader加载插件 ### 4、qobject_cast()测试接口...
10. Adding Text on Video 93 11. Conversion Between Formats 99 12. Time Operations 108 13. Mathematical Functions 113 14. Metadata and Subtitles 117 15. Image Processing 122 16. Digital Audio 128 17. ...