[AS3]as3初始化StageVideo事件侦听器
在应用程序初始化过程中设置 StageVideoAvailabilityEvent 和 VideoEvent 侦听器。例如,可以在 flash.events.Event.ADDED_TO_STAGE 事件处理函数中初始化这些侦听器。此事件可保证您的应用程序在舞台上可见
在应用程序初始化过程中设置 StageVideoAvailabilityEvent 和 VideoEvent 侦听器。例如,可以在 flash.events.Event.ADDED_TO_STAGE 事件处理函数中初始化这些侦听器。此事件可保证您的应用程序在舞台上可见;
- public class SimpleStageVideo extends Sprite
- private var nc:NetConnection;
- private var ns:NetStream;
- public function SimpleStageVideo()
- {
- // Constructor for SimpleStageVideo class
- // Make sure the app is visible and stage available
- addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
- }
- private function onAddedToStage(event:Event):void
- {
- //...
- // Connections
- nc = new NetConnection();
- nc.connect(null);
- ns = new NetStream(nc);
- ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
- ns.client = this;
- // Screen
- video = new Video();
- video.smoothing = true;
- // Video Events
- // the StageVideoEvent.STAGE_VIDEO_STATE informs you whether
- // StageVideo is available
- stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY,
- onStageVideoState);
- // in case of fallback to Video, listen to the VideoEvent.RENDER_STATE
- // event to handle resize properly and know about the acceleration mode running
- video.addEventListener(VideoEvent.RENDER_STATE, videoStateChange);
- //...
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...