[FMS]Flex写的基于Flash Media Serve的rtmp协议的播放器代码
[FMS]Flex写的基于Flash Media Serve的rtmp协议的播放器代码
[FMS]Flex写的基于Flash Media Serve的rtmp协议的播放器代码
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="VideoExample()">
- <mx:Script>
- <![CDATA[
- import flash.display.Sprite;
- import flash.events.*;
- import flash.media.Video;
- import flash.net.NetConnection;
- import flash.net.NetStream;
- //极酷播放器提示:视频文件地址
- private var videoURL:String = "IronMan.flv";
- private var connection:NetConnection;
- private var stream:NetStream;
- public function VideoExample():void {
- connection = new NetConnection();
- connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
- connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
- connection.connect("rtmp://localhost/oflaDemo");
- }
- //极酷播放器提示:状态回显
- 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.width = 400;
- video.height = 400;
- video.attachNetStream(stream);
- stream.play(videoURL);
- sprct.addChild(video);
- }
- private function securityErrorHandler(event:SecurityErrorEvent):void {
- trace("securityErrorHandler: " + event);
- }
- private function asyncErrorHandler(event:AsyncErrorEvent):void {
- // ignore AsyncErrorEvent events.
- }
- ]]>
- </mx:Script>
- <mx:VideoDisplay x="57" y="22" width="707" height="494"/>
- </mx:Application>
热门文章推荐
- 纯HLS(m3u8)跨平台技术(HLSPlayer,m3u8Player跨平台多终端)
- DiscuzX3.2酷播视频插件(dz论坛自定义视频插件带广告
- [微信视频]实现网站中的视频在微信平台上正常播放(超多组图)
- [rtsp]海康威视监控摄像头实现web端无插件监控实拍效果
- 很酷,酷播wordpress视频插件(支持PC/安卓/苹果跨平台播放)
- [组图]微信视频技术:支持微信视频直播和视频点播
- [AS3]as3.0的rtmp流媒体播放器写法源代码示例
- 一步一步教你制作FLV网页视频播放器
请稍候...