/*================================================================================== mp3 音乐文件,加载、播放;播放控制条实现 ===================================================================================*/ var mp3 = new Object(); mp3.load = function(url, target) { //delete target.onEnterFrame //this.sound.stop() //delete this.sound this.target = target; this.sound = new Sound(target); this.sound.loadSound(url,true); //this.sound.onLoad 首次加载有效,以后读取缓存失效; //读取缓存解决见 ctr.seekBarLoaded_mc.onEnterFrame /* this.sound.onLoad = function(success) { if (success) { if(ctr.status=="PLAY" && mp3.target.onEnterFrame==null){ctr.play_btn.onRelease();} }else{} }; */ this.sound.onSoundComplete = function() { if(this.duration>300){ ctr.start(); mp3.enter(target); } }; var snd = this.sound; var ctr = sys.ctrlMc; ctr.start = function(secondOffset,loop){ if(!ctr.seekBar_mc.onEnterFrame){ ctr.seekBar_mc.onEnterFrame = seekPrecess } //snd.stop() snd.start(secondOffset,loop) } ctr.reSize = function(){ sys.ctrlMc.seekBarWidth = sys.ctrlMc.seekBar_mc._width-( Math.floor(sys.ctrlMc.seek_mc._width)-1 ); //make width subtract 1 if(sys.ctrlMc.loadedPercent == 100){ sys.ctrlMc.seekBarLoaded_mc._width = sys.ctrlMc.seekBar_mc._width } } ctr.reSize() ctr.position = 0; //ms ctr.status = "PLAY"; //PLAY , PAUSE , STOP ctr.buffer = false ctr.seekMcStartX = 1 ctr.bufferPercent = 10 //缓冲10%,播放保留5%的预加载 ctr.loadedPercent = 1 //声音已经加载的百分比 ctr.duration = 1 var btnTip = function(target,str){ target.onRollOver = function(){ sys.tipShow(str,this) } target.onRollOut = function(){ sys.tipHide() } } btnTip(ctr.play_btn," 开始播放 ") btnTip(ctr.pause_btn," 暂停播放 ") btnTip(ctr.stop_btn," 停止播放 ") ctr.play_btn.onRelease = function() { ctr.status = "PLAY"; ctr.pause_btn._visible = true; ctr.start(ctr.position/1000); scr.play(); mp3.enter(mp3.target); } ctr.pause_btn.onRelease = function() { ctr.status = "PAUSE"; ctr.pause_btn._visible = false; ctr.position = snd.position; scr.pause(); snd.stop(); } ctr.stop_btn.onRelease = function() { ctr.status = "STOP"; ctr.pause_btn._visible = false; ctr.position = 0; delete ctr.seekBar_mc.onEnterFrame ctr.seekBarPlayed_mc._width = 0 ctr.seek_mc._x = ctr.seekMcStartX; scr.stop(); snd.stop(); } if(!autostart){ // autostart 外部参数 ctr.pause_btn.onRelease() scr.createBegin(); sys.removeLoad(); } ctr.seekBarLoaded_mc.onEnterFrame = function(){ ctr.loadedPercent = snd.getBytesLoaded()/snd.getBytesTotal()*100 ctr.duration = snd.duration/ctr.loadedPercent*100 this._width = ctr.seekBar_mc._width * ctr.loadedPercent/100 if( ctr.loadedPercent == 100){ ctr.buffer = false ctr.duration = snd.duration if(mp3.target.onEnterFrame==null && autostart ) ctr.play_btn.onRelease(); delete this.onEnterFrame } } ctr.seekBarPlayed_mc._width = 0 //ctr.seekBar_mc._visible = false; var seekPrecess = function () { if(ctr.status == "PLAY"){ var soundPercent = snd.position/ctr.duration if(soundPercent>1){ soundPercent=1 } if( ctr.loadedPercent==100 || (ctr.loadedPercent - soundPercent*100) >ctr.bufferPercent ){ ctr.seek_mc._x = ctr.seekBarWidth*soundPercent + ctr.seekMcStartX; ctr.seekBarPlayed_mc._width = ctr.seek_mc._x - ctr.seekMcStartX; if(ctr.buffer){ ctr.bufferPercent=5 //更长的播放时间 ctr.buffer = false //ctr.start(ctr.position/1000); //mp3.enter(mp3.target); //ctr.status = "PLAY"; ctr.pause_btn._visible = true; ctr.start(ctr.position/1000); scr.play(); mp3.enter(mp3.target); } }else{ if(!ctr.buffer){ ctr.bufferPercent=10 //更长的预加载时间 ctr.buffer = true //ctr.position = snd.position; //snd.stop(); //ctr.status = "PAUSE"; ctr.pause_btn._visible = false; ctr.position = snd.position; scr.pause(); snd.stop(); } } } } // seek MP3 all by seekBar_mc event ctr.seekBar_mc.onEnterFrame = seekPrecess; ctr.seekBar_mc.onPress = function() { ctr.seek_mc.nextFrame() var sbw = ctr.seekBarWidth*( ctr.loadedPercent==100?1:(ctr.loadedPercent-ctr.bufferPercent)/100 ) //var sbw = ctr.seekBarWidth if(sbw<1) sbw =1 ctr.seek_mc._x = (_xmouse-5)>sbw ? sbw : (_xmouse-5); startDrag(ctr.seek_mc, false, ctr.seekMcStartX, 0, sbw + 1, 0); //make drag add 1 ctr.seekBar_mc.onEnterFrame = function() { ctr.seekBarPlayed_mc._width = ctr.seek_mc._x - ctr.seekMcStartX; }; } ctr.seekBar_mc.onRelease = ctr.seekBar_mc.onReleaseOutside = function () { ctr.seek_mc.prevFrame() stopDrag(); if (ctr.status == "PLAY") { ctr.start( (ctr.seek_mc._x- ctr.seekMcStartX)/ctr.seekBarWidth*ctr.duration /1000 ); mp3.enter(mp3.target); ctr.seekBar_mc.onEnterFrame = seekPrecess; } else { delete ctr.seekBar_mc.onEnterFrame; ctr.position = (ctr.seek_mc._x-ctr.seekMcStartX)/ctr.seekBarWidth*ctr.duration ctr.seekBarPlayed_mc._width = ctr.seek_mc._x-ctr.seekMcStartX; } } // fullscreen ___________________________________ btnTip(ctr.fullscreen_btn," 全屏显示 ") ctr.fullscreen_btn._visible = System.capabilities.version.split(",")[0].split(" ").pop()>=9 if(ctr.fullscreen_btn._visible){ ctr.fullscreen_btn.onRelease = function(){ if(Stage["displayState"] == "fullScreen"){ //fscommand("fullscreen", false); Stage["displayState"] ="normal" btnTip(ctr.fullscreen_btn," 全屏显示 ") //sys.setMatrixFilter(ctr,"original") }else{ //fscommand("fullscreen", true); Stage["displayState"] ="fullScreen"; btnTip(ctr.fullscreen_btn," 退出全屏 ") //sys.setMatrixFilter(ctr,"invert") } } } // gg1 ___________________________________ btnTip(ctr.gg1_btn," 在线小游戏 ") ctr.gg1_btn.onRelease = function(){ getURL("http://www.ee1234.com","_blank") } // homepage ___________________________________ btnTip(ctr.make_btn," 我也要制作MTV ") ctr.make_btn.onRelease = function(){ getURL("http://www.qingcai.net/makemtv/welcome.aspx","_blank") } // rank ___________________________________ btnTip(ctr.rank_btn," MTV排行榜 ") ctr.rank_btn.onRelease = function(){ sys.createWin("rank"); } // volume ___________________________________ var vom = ctr.volume_mc vom.barMc = ctr.volume_mc.bar_mc vom.handleMc = ctr.volume_mc.handle_mc vom.switchBtn = ctr.volume_mc.switch_btn vom.barWidth = vom.barMc._width - (vom.handleMc._width-1) vom.handleMcStartX = vom.barMc._x vom.volumeNum = 100 vom.handleMc.step = 5 btnTip(vom.barMc," 音量调节 ") vom.barMc.onPress = function(){ vom.handleMc.nextFrame() var hx = (this._xmouse-4)>vom.barWidth ? vom.barWidth : (this._xmouse-4) if(hx<0) hx = 0 vom.handleMc._x = vom.handleMcStartX + hx; startDrag(vom.handleMc,false, vom.handleMcStartX, vom.barMc._y , vom.handleMcStartX+vom.barWidth,vom.barMc._y) vom.handleMc.onEnterFrame = function(){ vom.volumeNum = Math.round((vom.handleMc._x-vom.handleMcStartX)/vom.barWidth*100) snd.setVolume(vom.volumeNum) } } vom.barMc.onRelease = vom.barMc.onReleaseOutside = function () { vom.handleMc.prevFrame() stopDrag() vom.handleMc.step = Math.abs( vom.handleMc.step ) delete vom.handleMc.onEnterFrame } vom.switchBtn.onRelease = function(){ vom.handleMc.max = vom.volumeNum vom.handleMc.step = -vom.handleMc.step vom.handleMc.cur = snd.getVolume() vom.barMc._visible = false; vom.handleMc.onEnterFrame = function(){ if(this.step>0 && this.cur+this.step<=this.max || this.step<0 && this.cur+this.step>=0){ this.cur += this.step }else{ vom.barMc._visible = true; this.cur = this.step>0?this.max:0 delete this.onEnterFrame; } snd.setVolume(this.cur) this._x = vom.handleMcStartX + vom.barWidth*this.cur/100 } } // menu ___________________________________ var menu = ctr.menu_mc; menu.hide = function () { menu.body_mc._visible = false; }; menu.show = function () { menu.body_mc._visible = true; }; menu.itemButtonEvent = function (target) { target.onRollOver = function () { this.nextFrame(); this.t_txt.htmlText = this.label; }; target.onRollOut = function () { this.prevFrame(); this.t_txt.htmlText = this.label; }; }; menu.body_mc._visible = false; menu.lead_btn.onRollOver = menu.show; menu.body_mc.out_btn.onRollOver = (menu.body_mc.out_btn.onRollOut = menu.hide); var kalaokItem = menu.body_mc.kalaok_item_mc; kalaokItem.label = "卡拉OK模式"; kalaokItem.type_mc.gotoAndStop("check"); menu.itemButtonEvent(kalaokItem); kalaokItem.onRelease = function () { scr.kalaok = !scr.kalaok; kalaokItem.type_mc._visible = scr.kalaok; menu.hide(); }; kalaokItem.onRollOut(); kalaokItem.type_mc._visible = scr.kalaok; var effectItem = menu.body_mc.effect_item_mc; effectItem.label = "加载小饰品"; effectItem.type_mc.gotoAndStop("check"); menu.itemButtonEvent(effectItem); effectItem.onRelease = function () { scr.conMc.effectMc._visible = !scr.conMc.effectMc._visible; effectItem.type_mc._visible = scr.conMc.effectMc._visible; menu.hide(); }; effectItem.onRollOut(); effectItem.type_mc._visible = scr.conMc.effectMc._visible; var frameItem = menu.body_mc.frame_item_mc; frameItem.label = "加载相框"; frameItem.type_mc.gotoAndStop("check"); menu.itemButtonEvent(frameItem); frameItem.onRelease = function () { var tmp=!scr.conMc.frameMc._visible; scr.conMc.frameMc._visible = tmp frameItem.type_mc._visible = tmp menu.hide(); }; frameItem.onRollOut(); frameItem.type_mc._visible = scr.conMc.frameMc._visible; // var colorItem = menu.body_mc.color_item_mc; colorItem.label = "字幕色"; colorItem.type_mc.gotoAndStop("none"); colorItem.t_txt.htmlText = colorItem.label; var colorPane = menu.body_mc.colorpane_mc; var colorArr = [0xFF00FF,0x0000FF,0xFF0000]//,/*0x008000,0xFF8000,0x000000,0x808000,0x008080*/]; var clrMc,clrObj; for(var i=0;i