加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex播放器代码支持rtmp协议

发布时间:2020-12-15 04:19:01 所属栏目:百科 来源:网络整理
导读:? 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;? ?
 
 
  1. <?xml?version="1.0"?encoding="utf-8"?>? ?
  2. <mx:Application?xmlns:mx="http://www.adobe.com/2006/mxml"? layout="absolute"?initialize="VideoExample()">? ?
  3. <mx:Script>? ?
  4. <![CDATA[? ?
  5. ???? ?
  6. ????import?flash.display.Sprite;? ?
  7. ????import?flash.events.*;? ?
  8. ???????import?flash.media.Video;? ?
  9. ???????import?flash.net.NetConnection;? ?
  10. ???????import?flash.net.NetStream;? ?
  11. ???? ?
  12. ????private?var?videoURL:String?=?"IronMan.flv";? ?
  13. ??????????private?var?connection:NetConnection;? ?
  14. ??????????private?var?stream:NetStream;? ?
  15. ?????????? ?
  16. ?????????public?function?VideoExample():void?{? ?
  17. ????????????connection?=?new?NetConnection();? ?
  18. ????????????connection.addEventListener(NetStatusEvent.NET_STATUS,?netStatusHandler);? ?
  19. ????????????connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,? securityErrorHandler);? ?
  20. ????????????connection.connect("rtmp://localhost/oflaDemo");? ?
  21. ?????????}? ?
  22. ????????? ?
  23. ?????????private?function?netStatusHandler(event:NetStatusEvent):void?{? ?
  24. ??????????????switch?(event.info.code)?{? ?
  25. ??????????????????case?"NetConnection.Connect.Success":? ?
  26. ??????????????????????connectStream();? ?
  27. ??????????????????????break;? ?
  28. ??????????????????case?"NetStream.Play.StreamNotFound":? ?
  29. ??????????????????????trace("Unable?to?locate?video:?"?+?videoURL);? ?
  30. ??????????????????????break;? ?
  31. ??????????????}? ?
  32. ??????????}? ?
  33. ??? ?
  34. ????private?function?connectStream():void?{? ?
  35. ??????????????var?stream:NetStream?=?new?NetStream(connection);? ?
  36. ??????????????stream.addEventListener(NetStatusEvent.NET_STATUS,?netStatusHandler);? ?
  37. ??????????????stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR,?asyncErrorHandler);? ?
  38. ??????????????var?video:Video?=?new?Video();? ?
  39. ??????????????video.width?=?400;? ?
  40. ??????????????video.height?=?400;? ?
  41. ??????????????video.attachNetStream(stream);? ?
  42. ??????????????stream.play(videoURL);? ?
  43. ??????????????sprct.addChild(video);? ?
  44. ??????????}? ?
  45. ?????????? ?
  46. ??????????private?function?securityErrorHandler(event:SecurityErrorEvent):void?{? ?
  47. ??????????????trace("securityErrorHandler:?"?+?event);? ?
  48. ??????????}? ?
  49. ?????????? ?
  50. ??????????private?function?asyncErrorHandler(event:AsyncErrorEvent):void?{? ?
  51. ??????????????//?ignore?AsyncErrorEvent?events.? ?
  52. ??????????}? ?
  53. ]]>? ?
  54. </mx:Script>? ?
  55. <mx:VideoDisplay?id="sprct"?x="57"?y="22"?width="707"?height="494"/>? ?
  56. </mx:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读