Flex视频播放及其控制视频大小显示

<?xml version="1.0" encoding="utf-8"?> <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="completeHandler()"> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <![CDATA[ import com.esri.ags.layers.supportClasses.AttachmentInfo; import com.esri.events.BaseEvent; import mx.core.UIComponent; [Bindable] public var enterprise_name_label:String = ""; [Bindable] public var remarks_label:String = ""; [Bindable] public var url:String = ""; private var nc:NetConnection; private var ns:NetStream; private var video:Video; private var meta:Object; private var uic:UIComponent; private function init():void { // view.removeAllChildren(); if(ns != null){ ns.pause(); ns = null; } var nsClient:Object = {}; nsClient.onMetaData = ns_onMetaData; nsClient.onCuePoint = ns_onCuePoint; nc = new NetConnection(); nc.connect(null); ns = new NetStream(nc); ns.play("assets/images/20120507_120410.mp4"); ns.client = nsClient; video = new Video(); video.attachNetStream(ns); uic = new UIComponent(); uic.addChild(video); view.addChild(uic); } private function ns_onMetaData(item:Object):void { trace("meta"); meta = item; // Resize Video object to same size as meta data. video.width = 300; video.height = 200; // Resize UIComponent to same size as Video object. uic.width = video.width; uic.height = video.height; } private function ns_onCuePoint(item:Object):void { trace("cue"); } private function completeHandler():void{ BaseEvent.addListener(BaseEvent.ATTACHMENTINFO,setimageHandler); BaseEvent.addListener(BaseEvent.VIDEO_STOP,cancelHandler); } private function setimageHandler(event:BaseEvent):void{ if(ns != null){ ns.pause(); ns = null; } view.removeAllChildren(); var img:Image = new Image(); img.source = (event.data as AttachmentInfo).url; img.visible = true; img.width = 200; img.height =100; view.addChild(img); } private function cancelHandler(event:BaseEvent):void{ if(ns != null){ ns.pause(); ns = null; } } ]]> </fx:Script> <s:Rect top="0" bottom="0" left="0" right="0"> <s:fill> <s:SolidColor color="0xf0f0f0"/> </s:fill> </s:Rect> <mx:Form width="100%" height="100%"> <mx:FormItem label="备注:" horizontalAlign="right"> <s:Label text="{remarks_label}" id="remarks"/> </mx:FormItem> <mx:FormItem label="附件:" horizontalAlign="right"> <mx:HBox id="hboximg" width="100%" height="100%" maxWidth="200"> </mx:HBox> <mx:HBox id="hboxvedio" width="100%" height="100%" maxWidth="200"> <s:Image id="img1" source="assets/images/movie.png" click="init()"/> </mx:HBox> </mx:FormItem> <mx:FormItem horizontalAlign="right"> <mx:HBox id="view" width="100%" height="100%"> </mx:HBox> </mx:FormItem> </mx:Form> </s:Group>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值