任意拖动的视频播放器
任意拖动的视频播放器 //====================================================== //===============VIDEO SETUP=====视频设置============ //====================================================== //the playlist address _root.playlist == undefined ? playlist="http://yun.365.sh/s/TY2gc2.swf" : playlist=_root.playlist; // stage variables Stage.showMenu = false; Stage.scaleMode = "noScale"; stop(); // video Stream variables var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); // buffer video ns.setBufferTime(5); ns.onStatus = function(obj) { if (obj.code == "NetStream.Buffer.Full") { bufferClip._visible = false; } if(obj.code == "NetStream.Buffer.Empty") { bufferClip._visible = true; } }; var myVolume:Number = 0; var current_song:Number = 1; // control variables var scr = _root.main.controlBar.scrubber; var pr = scr.progres; var ld = scr.loader; var cb = _root.main.controlBar; var swidth = scr.back._width-37; //297-37 var pstart = -285; //-261 var dur:Number; // the percentage of the video loaded var lprog:Number = 0; var sign:String = "first"; main.theVideo.attachVideo(ns); // parsing the playlist xml files data_xml = new XML(); data_xml.ignoreWhite = true; data_xml.onLoad = loadData; data_xml.load(playlist); var aPath = new Array(); function loadData(success) { if (success) { // getting all titles and filenames songTitel = new Array(); audioTracks = new Array(); audioTracks.shuffle(); audioTracks = this.firstChild.childNodes; song_total = audioTracks.length; for (var i = 0; i<song_total; i++) { aPath.push(audioTracks[i].attributes.path); songTitel.push(audioTracks[i].attributes.title); // buiding playlist buttons bot.listContentMc.playlist.btn.duplicateMovieClip("btn"+i, i); bot.listContentMc.playlist["btn"+i]._y = bot.listContentMc.playlist.btn._y+i*int(bot.listContentMc.playlist.btn._height)+i; bot.listContentMc.playlist["btn"+i].txt = checkDigits(i+1)+". "+songTitel[i]; bot.listContentMc.playlist["btn"+i].hit.onPress = function() { listClick(this._parent.getDepth()+1); }; } //checking autostart mode autoStart = this.firstChild.attributes.autoStart; if (autoStart == "yes") { playtime(); } else if (autoStart == "no") { main.controlBar.scrubber.perload.text = "OK"; cb.plabel.play(); } else if (autoStart == "random") { current_song = random(song_total)+1; playtime(); } else { current_song = int(this.firstChild.attributes.autoStart); playtime(); } } // done ! all loaded succesfully. purging trash delete audioTracks; delete data_xml; } //========================================================== //===============VIDEO CONTROLS=====视频控件================= //========================================================== function playtime() { bufferClip._visible = false; AudioPath = aPath[current_song-1]; main.welcome._visible = false; ns.play(AudioPath); cb.plabel.gotoAndStop(1); } // get the length of the Movie ns.onMetaData = function(obj) { dur = obj.duration; }; _root.onEnterFrame = videoUpdate; // the state of the video loading... function videoUpdate() { var prog = ns.time/dur; main.welcome.title.text = "<< " + songTitel[current_song-1] + ">> is preparing . "; lprog = ns.bytesLoaded/ns.bytesTotal; main.controlBar.scrubber.loaded._width = lprog*290; pr._x = -285+(swidth*prog); ns.onStatus = function(infoObject:Object) { if(infoObject.code == "NetStream.Play.Start") { sign = "started"; } else if(infoObject.code == "NetStream.Play.Stop") { sign = "closed"; if (autoStart == "random") { current_song = random(song_total)+1; } else { current_song == song_total ? current_song=1 : current_song++; } cb.plabel.play(); } }; if(sign == "started") { main.welcome._visible = false; bot.currentPlay.text = checkDigits(current_song)+". "+songTitel[current_song-1]; main.controlBar.scrubber.perload.text = Math.round(lprog*100)+"%"; hadPlayed.text = Math.floor(ns.time/60)+" m "+Math.round(ns.time%60)+" s "+Math.floor(prog*100)+" %"; timetext.text = Math.floor(dur/60)+" m "+Math.round(dur%60)+" s"; } else if(sign == "closed") { main.controlBar.scrubber.perload.text = "Closed"; hadPlayed.text = "Previous one closed"; main.welcome._visible = true; timetext.text = "none loaded"; } else if(sign == "first") { main.controlBar.scrubber.perload.text = "OK"; timetext.text = "默认的视频";//default Vedio OK hadPlayed.text = "玩家可以"; //Player OK } } function listClick(prm) { delete pausepos; current_song = prm; ns.stop(); playtime(); sign = "select"; } // list scroller bot.listContentMc.list_bg.onEnterFrame = function() { if (this.hitTest(_root._xmouse, _root._ymouse) == true && this._parent.playlist._height>this._height) { ymin = this._y+this._height-this._parent.playlist._height; ymax = this._y+3; conv = (this._ymouse-15)*1.3/this._height; conv>1 ? conv=1 : null; conv<0 ? conv=0 : null; this._parent.playlist.easeY(ymax-conv*(ymax-ymin)); } }; bot.listContentMc.playlist.setMask(bot.listContentMc.list_bg); MovieClip.prototype.easeY = function(t) { this.onEnterFrame = function() { this._y = int(t-(t-this._y)/1.5); if (this._y>t-1 && this._y<t+1) { delete this.onEnterFrame; } }; }; // prefixing a 0 to the time function checkDigits(toCheck) { return (toCheck<10) ? toCheck="0"+toCheck : toCheck; } // end playlist cb.replayer.onRollOver = function() { showTip("Replay Video"); }; cb.replayer.onRollOut = cb.replayer.onPress=function () { removeTip(); }; cb.replayer.onRelease = function() { ns.seek(0); ns.pause(false); cb.plabel.gotoAndStop(1); }; var rewInt; cb.rewinder.onRollOver = function() { showTip("Rewind"); }; cb.rewinder.onRollOut = function() { removeTip(); }; cb.rewinder.onPress = function() { rewInt = setInterval(rewind, 200); ns.pause(true); removeTip(); }; cb.rewinder.onRelease = cb.rewinder.onReleaseOutside=function () { clearInterval(rewInt); ns.pause(false); }; function rewind() { ns.seek(ns.time-30); if (ns.time == 0) { clearInterval(rewInt); ns.pause(false); } // end if } cb.player.onRollOver = function() { showTip("Play / Pause"); }; cb.player.onRollOut = cb.player.onPress=function () { removeTip(); }; cb.player.onRelease = function() { if(sign == "closed" || sign == "first" || sign == "select") { playtime(); } else ns.pause(); cb.plabel.play(); }; cb.stopper.onRollOver = function() { showTip("Stop Video"); }; cb.stopper.onRollOut = cb.stopper.onPress=function () { removeTip(); }; cb.stopper.onRelease = function() { ns.seek(0); ns.pause(true); cb.plabel.gotoAndStop(2); removeTip(); }; var ffInt; cb.fforwarder.onRollOver = function() { showTip("Fast Forward"); }; cb.fforwarder.onRollOut = function() { removeTip(); }; cb.fforwarder.onPress = function() { removeTip(); ffInt = setInterval(ff, 200); }; cb.fforwarder.onRelease = cb.fforwarder.onReleaseOutside=function () { clearInterval(ffInt); /*if(ns.time / dur > .95) { ns.seek(0); ns.pause(false); }*/ }; function ff() { if (ns.time/dur<.95) { ns.seek(ns.time+1); } else { clearInterval(ffInt); } } pr.scrubba.onPress = function() { //ns.pause(true); _root.onEnterFrame = scrubba; pr.startDrag(false, -285, pr._y, -25, pr._y); }; pr.scrubba.onRelease = pr.scrubba.onReleaseOutside=function () { _root.onEnterFrame = videoUpdate; //ns.pause(false); pr.stopDrag(); removeTip(); }; function scrubba() { var p = (pr._x-pstart)/swidth; if (p<=lprog) { ns.seek(p*dur); } else { ns.seek(lprog); } main.tooltip.datext.text = Math.floor(p*100)+" % 处理";//processing main.tooltip._x = Math.round(main._xmouse); main.tooltip._y = Math.round(main._ymouse); main.tooltip._visible = true; } main.controlBar.scrubber.back.onRelease = controlBar.scrubber.back.onReleaseOutside=function () { var p = (this._xmouse-37)/swidth; if (p<=lprog) { ns.seek(p*dur); } else { ns.seek(lprog); } }; //====================================================== //==============SOUND CONTROL=======声音控制============= //====================================================== _root.createEmptyMovieClip("vidsound", _root.getNextHighestDepth()); vidsound.attachAudio(ns); var sou:Sound = new Sound(vidsound); sou.setVolume(75); var startxs = main.controlBar.vol._x; main.controlBar.vol._x = startxs+(70*.75); main.controlBar.vol.onPress = function() { this.startDrag(false, startxs+3, this._y, startxs+58, this._y); main.tooltip._x = Math.round(main._xmouse); main.tooltip._y = 554; this.onEnterFrame = voller; }; main.controlBar.vol.onRollOver = function() { showTip("Volume"); }; main.controlBar.vol.onRollOut = function() { removeTip(); }; main.controlBar.vol.onRelease = main.controlBar.vol.onReleaseOutside = function () { this.stopDrag(); removeTip(); delete this.onEnterFrame; }; function voller() { var perc = ((main.controlBar.vol._x-544)/(55)); sou.setVolume(Math.ceil(perc*100)); myVolume = sou.getVolume(); main.tooltip.datext.text = sou.getVolume()+"% Volume"; main.tooltip._x = Math.round(main._xmouse); main.tooltip._y = Math.round(main._ymouse); main.tooltip._visible = true; } //====================================================== //==============TOOL TIPS=======工具提示================== //====================================================== var ti:Number; function showTip(datext) { ti = getTimer(); main.tooltip.datext.text = datext; main.tooltip.onEnterFrame = function() { var tempti = getTimer(); if (tempti-ti>500) { this._x = Math.round(main._xmouse); this._y = Math.round(main._ymouse); main.tooltip._visible = true; } }; } function removeTip() { main.tooltip._visible = false; delete main.tooltip.onEnterFrame; } main.tooltip._visible = false; main.mute.onRelease = function() { if (sou.getVolume() == 0) { sou.setVolume(myVolume); cb.vol._x = 544+63*myVolume/100; } else { myVolume = sou.getVolume(); sou.setVolume(0); cb.vol._x = 544; } main.bugle.play(); }; main.mute.onRollOver = function() { showTip("切换静音");//Toggle Mute }; main.mute.onRollOut = function() { removeTip(); }; //dragging main.window.onPress = function() { this._parent.startDrag(); this._parent.swapDepths(5); bot.swapDepths(4); }; bot.listTitleBar.onPress = bot.listContentMc.listContent.onPress =function() { bot.startDrag(); bot.swapDepths(5); main.swapDepths(4); }; main.window.onRelease = main.playerTitleBar.onReleaseOutside = function() { this._parent.stopDrag(); }; bot.listTitleBar.onRelease = bot.listTitleBar.onReleaseOutside = bot.listContentMc.listContent.onRelease = bot.listContentMc.listContent.onReleaseOutside = function() { bot.stopDrag(); }; // hide or show the playList main.plBut.onRelease = function() { (bot._visible == true)?bot._visible = false:bot._visible = true; }; main.plBut.onRollOver = function() { showTip("播放列表");//PlayList }; main.plBut.onRollOut = function() { removeTip(); }; bot.close.onRelease = function() { bot._visible = false; } bot.small.onRelease = function() { bot.smallContent.play(); (bot.listContentMc._visible == true)?bot.listContentMc._visible = false:bot.listContentMc._visible = true; }
- 1
- 哦芯依旧2015-12-12样式不好看
- 粉丝: 1
- 资源: 16
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助