台灣最大程式設計社群網站
線上人數
1058
 
會員總數:245121
討論主題:189030
歡迎您免費加入會員
討論區列表 >> CSS/HTML5/Bootstarp >> 請問NetStream的puase這樣寫 為何停不了影片
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
請問NetStream的puase這樣寫 為何停不了影片
價值 : 30 QP  點閱數:1874 回應數:0

樓主

gray
初學者
110 77
1192 101
發送站內信

舞台綁了文件類別 PersonalVideo.as
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.NetStream;
import PersonalVideo_Flv;

public class PersonalVideo extends MovieClip {
public static var _RootStage:Stage;
public static var flvUrl:String = 'mv_20090527181441.flv';

public function PersonalVideo():void {
PersonalVideo._RootStage = this.stage;
_playBtn.addEventListener(MouseEvent.CLICK, playHandler);
_pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);

}
public function playHandler(evt:MouseEvent) {
var getFlv:PersonalVideo_Flv = new PersonalVideo_Flv();
getFlv.setPlay();
}
public function pauseHandler(evt:MouseEvent) {
var getFlv:PersonalVideo_Flv = new PersonalVideo_Flv();
getFlv.setPause();
}
public function stopHandler(evt:MouseEvent) {
}
}
}


另外一隻 PersonalVideo_Flv.as
package {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.*;
import flash.media.Video;
public class PersonalVideo_Flv extends Sprite {
private var nc:NetConnection;
private var ns:NetStream;
private var vid:Video;
private var client:Object;
private var client2:Object;
public function PersonalVideo_Flv():void {
// Initialize net stream
nc = new NetConnection();
nc.connect(null);// Not using a media server.
ns = new NetStream(nc);
// Add video to stage
vid = new Video(460,260);
MTV_PersonalVideo._RootStage.addChild(vid);
vid.x = ( PersonalVideo._RootStage.stageWidth / 2) - ( vid.width / 2 );
vid.y = ( PersonalVideo._RootStage.stageHeight / 2) - ( vid.height / 2 ) - 5;
}
public function setPlay(){
//Set Smoothing
vid.smoothing=true;
// Play video
vid.attachNetStream( ns );
ns.play(MTV_PersonalVideo.flvUrl);
// Add callback method for listening on
// NetStream meta data
client = new Object();
ns.client = client;
client.onMetaData = ShowData;
}
public function setPause(){
ns.pause();
trace("pause");
}
public function setStop(){
}
function ShowData(info:Object):void {
var key:String;
for (key in info) {
trace(key + ": " + info[key]);
}
}
}
}

本篇文章發表於2009-06-12 16:01
別忘捐VP感謝幫助你的人 新手會員瞧一瞧
目前尚無任何回覆
   

回覆
如要回應,請先登入.