做了个播放器问题好多请指教
我参考教程自己做了个播放器,现有几个问题无法解决,请各位看看帮忙一下。1-如何才能让视频点击play后才播放不要自动播放。
2-进度条宽度如何和视频长度匹配,现在的进度条太长了都跑出画面了。
3-滑块不能自由拖动。
代码如下:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var myVideo:Video;
myVideo.attachVideo(ns);
ns.play("http://www.);
rewind_btn.onRelease = function(){
ns.seek(0);
}
play_btn.onRelease = function(){
ns.pause();
}
pause_btn.onRelease = function(){
ns.pause();
}
var percent_Loaded:Number = 0;
loader.loadBar._xscale = percent_Loaded;
function videoStatus(){
var videoTotal:Number = ns.bytesTotal;
var videoLoaded:Number = ns.bytesLoaded;
percent_Loaded = videoLoaded /videoTotal*100;
loader.loadBar._xscale = percent_Loaded;
}
var videoInterval = setInterval(videoStatus,100);
var percent_Loaded:Number = 0;
loader.loadBar._xscale = percent_Loaded;
loader.playBar._xscale = 0;
var duration:Number;
ns.onMetaData = function(obj:Object){
duration = obj.duration;
};
function videoStatus(){
var videoTotal:Number = ns.bytesTotal;
var videoLoaded:Number = ns.bytesLoaded;
percent_Loaded = videoLoaded /videoTotal*100;
loader.loadBar._xscale = percent_Loaded;
loader.scrub._x = ns.time / percent_Loaded * loader.loadBar._width;
loader.playBar._xscale = ns.time / percent_Loaded *100;
}
var videoInterval = setInterval(videoStatus,100);
var scrubInterval;
loader.scrub.onPress = function(){
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,loader.loadBar._width,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function(){
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
}
function scrubit(){
ns.seek(Math.floor((loader.scrub._x / loader.loadBar._width)*duration));
loader.playBar._xscale = loader.scrub._x / loader.loadBar._width *100;
}
vSound.attachAudio(ns);
var video_sound:Sound = new Sound(vSound);
vSound.onRelease = function(){
if(this.vol == 100){
video_sound.setVolume(0);
this.gotoAndStop(2);
}else{
video_sound.setVolume(100);
this.gotoAndStop(1);
}
}