VideoPlayer の使用を許可しない Red5 のカスタム認証メカニズム (CRAM-MD5) があるため、flash.media.Video コンポーネントを使用してリモート ビデオ ファイルを再生する必要があります。OpenVideoPlayer を使用しようとしましたが、サーバー側で失敗しました (呼び出しの実行中にエラーが発生しました: Service: null Method: play Num Params: 3 0: test/avatar.flv 1: NaN 2: NaN)。
Video コンポーネントの上部に、再生、一時停止、停止、巻き戻し、進行状況バーのコントローラーを配置するだけです。誰かがこれの簡単なビューを勧めてくれませんか? または、任意のソリューションで問題ありません。
更新: サンプル コード、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>