求flex 播放视频视频销售地址!

1 &?xml version="1.0" encoding="utf-8"?&
2 &s:Application xmlns:fx="/mxml/2009"
xmlns:s="library:///flex/spark"
xmlns:mx="library:///flex/mx"
creationComplete="init();"
minWidth="955"
minHeight="600"&
&fx:Script&
import flash.display.S
import flash.events.*;
import flash.media.V
import flash.net.NetC
import flash.net.NetS
import flash.events.E
private var videoName:String = "sample";
private var connection:NetC
private var stream:NetS
protected function button1_clickHandler(event:MouseEvent):void
VideoExample();
connection.connect(textdz.text);
protected function button2_clickHandler(event:MouseEvent):void
VideoExample();
connection.connect(null);
public function onBWDone ():void{}
public function VideoExample():void
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
connection.client=this;
private function netStatusHandler(event:NetStatusEvent):void
switch (.code)
case "NetConnection.Connect.Success":
connectStream();
trace("NetConnection.Connect.Success : " + videoName);
case "NetStream.Play.StreamNotFound":
trace("Unable to locate video: " + videoName);
private function connectStream():void
stream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
stream.client = {};
stream.bufferTime = 0 ;
stream.play(texturl.text);
var video:Video = new Video() ;
video.smoothing = true ;
video.width = 480 ;
video.height = 290 ;
video.attachNetStream(stream);
sprct.addChild(video);
private function securityErrorHandler(event:SecurityErrorEvent):void
trace("securityErrorHandler: " + event);
private function asyncErrorHandler(event:AsyncErrorEvent):void
trace("asyncErrorHandler: " + event);
&/fx:Script&
&s:Label x="21" y="26" text="地址:" verticalAlign="middle"/&
&s:TextInput id="textdz" x="21" y="46" width="365" text="rtmp://localhost/vod"/&
&s:TextInput id="texturl" x="19" y="83" width="365" text="../videos/liuhan_test.f4v"/&
&s:Button x="18" y="118" label="开始_FMS" click="button1_clickHandler(event)"/&
&s:Button x="116" y="118" width="79" label="本地视屏" click="button2_clickHandler(event)"/&
&s:Scroller
x="116" y="152" width="637" height="355"
&s:VGroup id="VG" width="100%" height="100%" &
&s:VideoDisplay id="sprct" width="600" height="300" scaleMode="none"/&
&/s:VGroup&
&/s:Scroller&
106 &/s:Application&
阅读(...) 评论()Flex在线视频聊天 求解
&因为是前几天才学Flex,我现在要做一个在线视频聊天的东西,就用FMS+Flex,在网上找了一些例子,情况是只能在自己电脑上看自己,我在别的电脑上连接我的电脑的话就不行,两台电脑不可以看见对方。不知道怎么解决。现在我把Flex代码打包放在这,希望能获得能者的帮助。小弟感激不尽。
&?xml version=&1.0& encoding=&utf-8&?&
&mx:Application xmlns:mx=&/2006/mxml& layout=&absolute& fontSize=&12& height=&388&&
&mx:Panel x=&10& y=&10& width=&340& height=&282& layout=&absolute& title=&视频发布端&&
&mx:VideoDisplay x=&0& y=&0& width=&320& height=&240& id=&PublishVideo&/&
&/mx:Panel&
&mx:Panel x=&366& y=&10& width=&340& height=&282& layout=&absolute& title=&视频接收端& id=&playPan&&
&mx:VideoDisplay x=&0& y=&0& width=&320& height=&240& id=&RecordVideo& /&
&/mx:Panel&
&mx:Button x=&106& y=&316& label=&发布视频& fontWeight=&normal& click=&onPublishClick()&/&
&mx:Button x=&488& y=&317& label=&接收视频& fontWeight=&normal& click=&onRecordClik()&/&
&mx:Script&
&![CDATA[ import flash.events.*; private var pnc:NetC private var rnc:NetC private var pns:NetS //发布流 private var rns:NetS private var cam:C private var mic:M private var video:V private function onPublishClick():void {
pnc = new NetConnection();
pnc.connect(&rtmp://localhost/PublishStreams&);
pnc.addEventListener(NetStatusEvent.NET_STATUS,onPublishNetStatusHandler);
cam = Camera.getCamera();
mic = Microphone.getMicrophone(); this.PublishVideo.attachCamera(cam);
} private function onPublishNetStatusHandler(evt:NetStatusEvent):void { this.lbPublish.text=. if(.code==&NetConnection.Connect.Success&)
pns = new NetStream(pnc);
pns.attachAudio(mic);
pns.attachCamera(cam);
pns.client=this;
pns.publish(&publishName&,&live&);
} private function onRecordClik():void {
rnc = new NetConnection();
rnc.connect(&rtmp://localhost/PublishStreams&);
rnc.addEventListener(NetStatusEvent.NET_STATUS,onReordNetStatusHandler);
} private function onReordNetStatusHandler(evt:NetStatusEvent):void { this.lbRecord.text=. if(.code==&NetConnection.Connect.Success&)
rns = new NetStream(rnc);
rns.client=this;
video = new Video();
video.width=320;
video.height=240;
video.attachNetStream(rns); this.RecordVideo.addChild(video);
rns.play(&publishName&,&live&); //这里的publishName必须与发布流的流名一致
&/mx:Script&
&mx:Label x=&35& y=&348& width=&304& id=&lbPublish&/&
&mx:Label x=&391& y=&348& width=&296& id=&lbRecord&/&
&/mx:Application&
--- 共有 1 条评论 ---
我们要用的是asp.net,red5好像是java的吧
这个是我修改以后的,还是在自己电脑上上测试通过,
&?xml version=&1.0& encoding=&utf-8&?&
&mx:Application xmlns:mx=&/2006/mxml& layout=&absolute& fontSize=&12& height=&388&&
&mx:Panel x=&10& y=&10& width=&340& height=&282& layout=&absolute& title=&视频发布端&&
&mx:VideoDisplay x=&0& y=&0& width=&320& height=&240& id=&PublishVideo&/&
&/mx:Panel&
&mx:Panel x=&366& y=&10& width=&340& height=&282& layout=&absolute& title=&视频接收端& id=&playPan&&
&mx:VideoDisplay x=&0& y=&0& width=&320& height=&240& id=&RecordVideo& /&
&/mx:Panel&
&mx:Button x=&106& y=&316& label=&发布视频& fontWeight=&normal& click=&onPublishClick()&/&
&mx:Button x=&488& y=&317& label=&接收视频& fontWeight=&normal& click=&onRecordClik()&/&
&mx:Script&
import flash.events.*;
import mx.controls.A
private var pnc:NetC
private var rnc:NetC
private var pns:NetS //发布流
private var rns:NetS
private var cam:C
private var mic:M
private var video:V
private var puN:S
private var reN:S
private function onPublishClick():void
pnc = new NetConnection();
pnc.connect(&rtmp://192.168.0.110/PublishStreams&);
pnc.addEventListener(NetStatusEvent.NET_STATUS,onPublishNetStatusHandler);
cam = Camera.getCamera();
mic = Microphone.getMicrophone();
this.PublishVideo.attachCamera(cam);
puN=this.publishName.
//Alert.show(puN);
private function onPublishNetStatusHandler(evt:NetStatusEvent):void
this.lbPublish..
.code==&NetConnection.Connect.Success&)
pns = new NetStream(pnc);
pns.attachAudio(mic);
pns.attachCamera(cam);
pns.client=
pns.publish(puN,&live&);
this.publishName.editable=
private function onRecordClik():void
rnc = new NetConnection();
reN=this.receiveName.
rnc.connect(&rtmp://192.168.0.110/PublishStreams&);
rnc.addEventListener(NetStatusEvent.NET_STATUS,onReordNetStatusHandler);
private function onReordNetStatusHandler(evt:NetStatusEvent):void
this.lbRecord..
.code==&NetConnection.Connect.Success&)
rns = new NetStream(rnc);
rns.client=
video = new Video();
video.width=320;
video.height=240;
video.attachNetStream(rns);
this.RecordVideo.addChild(video);
rns.play(reN,&live&);
//这里的publishName必须与发布流的流名一致
this.receiveName.editable=
&/mx:Script&
&mx:Label x=&35& y=&348& width=&304& id=&lbPublish&/&
&mx:Label x=&391& y=&348& width=&296& id=&lbRecord&/&
&mx:TextInput x=&184& y=&316& id=&publishName&/&
&mx:TextInput x=&566& y=&317& width=&140& id=&receiveName&/&
&/mx:Application& 用其他电脑连接还是不行
假设A,B两个人,那么A发布的流名字应该为streamA, B发布streamB,然后A播放streamB, B播放streamA。
你这个代码看起来是A,B发布的名字都是publishName,并且连接服务器的地址还是localhost,这个错误太严重了
首先是需要把netconnection对象连接的时候,传你局域网的ip,比如192.168.1.140之类的,然后在发布的时候,两端使用不同的名字发布,再播放对方的流名字(测试的话,可以先用文本框输入流名字)。
--- 共有 1 条评论 ---
你帮我看看,是不是,单独Flex就是不行啊??必须要和asp或者其他整合才可以求大神帮忙,如何用flex搞出爱奇艺视频的VIP
求大神帮忙,如何用flex搞出爱奇艺视频的VIP
var sogou_ad_id=731547;
var sogou_ad_height=160;
var sogou_ad_width=690;视频地址_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
上传于||暂无简介
你可能喜欢}

我要回帖

更多关于 flex 播放视频 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信