トップへ戻るニュースフォーラムFLASH-ML 過去ログBak@Flaダウンロードよくある質問と答
ログイン
ユーザ名:

パスワード:


パスワード紛失

新規登録
メインメニュー
メイン
   コーダーズルーム【スクリプト系】
     Videoオブジェクトでキューポイントを使う
投稿するにはまず登録を

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
永井勝則
Åê¹ÆNo.32616
投稿日時: 2007-3-24 14:12
職人
居住地: 白馬村
投稿: 796
使用環境:
Windows 7 :Flash CS4:
10.6.8 :Flash CS5.5
Videoオブジェクトでキューポイントを使う
前に投稿されていたFMS2でplaylistを自動的に再生する方法
の中で、少し触れた
VideoPlayerクラスを使わないで、キューポイントを取得する方法の
試作コードです。
イベント/リスナーの使い方を調べて、何とか動くようになりました。
ここはこうした方がよいとか、こうもできるとかいう議論のたたき台にでもなれば”本望”です。
実際には、FLVPlaybackコンポーネントやVideoPlayerクラスを使えばよいので、
実用的なコードではないですが、このイベント/リスナー形式はほかにも応用できます。

//VideoCuePoint.asファイル
/*指定された.flvファイルを再生し、flvファイルに埋め込まれたキューポイントを
含むイベントオブジェクトを返す*/
import mx.utils.Delegate;
class VideoCuePoint extends MovieClip {
	private var _video:Video;
	private var _nc:NetConnection;
	private var _ns:NetStream;
	//
	private var dispatchEvent:Function;
	public var addEventListener:Function;
	public var removeEventListener:Function;
	//
	public function VideoCuePoint() {
		mx.events.EventDispatcher.initialize(this);
		//
		_nc = new NetConnection();
		_nc.connect(null);
	}
	public function videoPlay(fileName:String):Void {
		_ns = new NetStream(_nc);
		var sendCue:Function = Delegate.create(this, this.onCuePointCustom);
		_ns.onCuePoint = function(info:Object) {
			//通常はここで情報をとる
			sendCue(info);
		};
		_video.attachVideo(_ns);
		_ns.play(fileName);
	}
	private function onCuePointCustom(info:Object):Void {
		var eventObject:Object = new Object();
		eventObject.type = "onCuePoint";
		eventObject.name = info.name;
		eventObject.time = info.time;
		this.dispatchEvent(eventObject);
	}
	public function addListener(eventName:String, listener:Object):Void {
		this.addEventListener(eventName, listener);
	}
	public function removeListener(eventName:String, listener:Object):Void {
		this.addEventListener(eventName, listener);
	}
}




//FLAファイル
import mx.controls.TextArea;
var info_txt:TextArea;
//video_mcムービークリップの中には_videoというインスタンス名のVideoオブジェクトを置く。
//リンケージをVideoCuePointに設定。
var video_mc:VideoCuePoint;
//リスナーはメインのタイムライン
var listener = this;
listener.onCuePoint = function(evt:Object) {
	displayInfo(evt);
};
function displayInfo(evt:Object):Void {
	info_txt.text += "cuePoint : "+evt.name+"\n";
	info_txt.text += "時間 : "+evt.time+"\n";
	info_txt.text += "イベント : "+evt.type+"\n";
	info_txt.vPosition = info_txt.maxVPosition;
}
video_mc.addListener("onCuePoint", listener);
//再生はFMSでなく、Webサーバー上
var flv:String="FLVファイル名.flv"
video_mc.videoPlay(flv);


----------------
永井勝則:
himco.jp :

スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ

投稿するにはまず登録を
 
Copyright (C) 2003 FLASH-japan. All rights reserved.
Powered by Xoops