我必須使用flash.media.Video組件來播放遠程視頻文件,因爲我在Red5中有一個不允許使用VideoPlayer的自定義身份驗證機制(CRAM-MD5)。我試圖使用OpenVideoPlayer,但它在服務器端失敗(Error execution execution:Service:null方法:播放Num Params:3 0:test/avatar.flv 1:NaN 2:NaN)。視頻組件的簡單視圖
我只需要在視頻組件的頂部有控制器:播放,暫停,停止,倒帶,進度條。請有人可以爲我推薦一個簡單的視圖嗎?或者任何解決方案都可以!
更新: 一個示例代碼,該togglePause工作不正常:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="640" minHeight="480"
initialize="init();">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.globalization.Collator;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
private var nc:NetConnection;
private var ns:NetStream;
private var video:Video;
private var meta:Object;
private var videoURL:String = "test/avatar.flv";
private function init():void {
var params:Object = {
user: "user",
video_id: 2
};
nc = new NetConnection();
nc.connect("rtmp://localhost/myapp", params);
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS,onConnectionStatus);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onErrorHandler);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
}
private function onConnectionStatus(event:NetStatusEvent):void {
var nsClient:Object = {};
nsClient.onMetaData = ns_onMetaData;
nsClient.onCuePoint = ns_onCuePoint;
ns = new NetStream(nc);
ns.play(videoURL);
ns.client = nsClient;
video = new Video();
video.attachNetStream(ns);
uic.addChild(video);
}
private function onErrorHandler(event:AsyncErrorEvent):void{
}
private function onSecurityError(event:SecurityErrorEvent):void{
}
private function ns_onMetaData(item:Object):void {
}
private function ns_onCuePoint(item:Object):void {
}
public function onBWDone():void {
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:SpriteVisualElement id="uic" x="0" y="0" width="320" height="240" />
<mx:ControlBar x="10" y="330">
<mx:Button label="Play/Pause" click="ns.togglePause();" />
<mx:Button label="Rewind" click="ns.seek(0); ns.pause();" />
</mx:ControlBar>
我試圖自己做,但togglePause()有問題 - 凍結 - 我甚至沒有開始使它的進度條部分...:S – haxpanel