wrongdoer 0 Denunciar post Postado Dezembro 23, 2010 Fala galera, bom é o seguinte achei um script na internet pronto de um player do youtube, que aparece o vídeo e uma lista do lado em meu site, feito em flash. Porém quando clico em outros links do site o vídeo para, mas o áudio do vídeo contnua tocando, alguém sabe como para a execução do áudio? Aqui está o código: import mx.transitions.Tween; import mx.transitions.easing.*; System.security.allowDomain("youtube.com","http://youtube.com","www.youtube.com","8.7.217.31"); controlButtons.playPause.gotoAndStop("play"); Stage.scaleMode = "noScale"; Stage.align = "TL"; Stage.showMenu = false; // create a listener object for the MovieClipLoader to use var ytPlayerLoaderListener:Object = { onLoadInit: function() { loadInterval = setInterval(checkPlayerLoaded, 250); } }; var loadInterval:Number; var theVideos:Array = new Array(); var whoIsOn:Number = 0; var nodes; var theTitles:Array = new Array(); var theDetails:Array = new Array(); var shuffle:Boolean = false; var repeat:Boolean = false; var playInterval:Number; var firstTimePlayed:Boolean = true; function startPlay(){ clearInterval(playInterval); textChange(); ytplayer.loadVideoById(theVideos[whoIsOn], 0); } function beforeStartPlay(){ clearInterval(playInterval); playInterval = setInterval(startPlay, 1000); theCurrentItem(); ytplayer.pauseVideo(); } function checkPlayerLoaded():Void { if (ytplayer.isPlayerLoaded()) { ytplayer.setSize(456, 340); ytplayer._x = 10; ytplayer._y = 10; ytplayer.addEventListener("onStateChange", onPlayerStateChange); ytplayer.addEventListener("onError", onPlayerError); clearInterval(loadInterval); } } function checkPlayerLoaded2():Void { firstTimePlayed = false; if (ytplayer.isPlayerLoaded()) { startPlay(); theCurrentItem(); whoIsOn = 0; clearInterval(loadInterval2); } } /*onStateChange - This event is fired whenever the player's state changes. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5). When the SWF is first loaded it will broadcast an unstarted (-1) event. When the video is cued and ready to play it will broadcast a video cued event (5).*/ function onPlayerStateChange(newState:Number) { trace("New player state: "+ newState); if(newState == 2 && controlButtons.playPause._currentframe == 30){ controlButtons.playPause.gotoAndStop("playOver"); }else if(controlButtons.playPause._currentframe == 20){ controlButtons.playPause.gotoAndStop("pause"); } if(newState == 0){ if(shuffle == false){ if(repeat == false){ whoIsOn++; if(whoIsOn >= nodes.length){ whoIsOn = 0; listBox.dragger._y = 0; } } }else{ if(repeat == false){ whoIsOn = Math.floor(Math.random()*(nodes.length-1)); } } beforeStartPlay(); } if(newState == 1){ if(_root.get_highest_quality == "true"){ theQuality(); } progressBar.onEnterFrame = videoUpdate; butArray[whoIsOn].theTime.text = getTimecode(ytplayer.getDuration()); } if(newState == 5){ controlButtons.playPause.gotoAndStop("play"); } } function onPlayerError(errorCode:Number) { //trace("An error occurred: "+ errorCode); errorItem(); //if(errorCode == 100){ whoIsOn++; if(whoIsOn >= nodes.length){ whoIsOn = 0; } beforeStartPlay(); //} } // create a MovieClipLoader to handle the loading of the player var ytPlayerLoader:MovieClipLoader = new MovieClipLoader(); ytPlayerLoader.addListener(ytPlayerLoaderListener); // load the player ytPlayerLoader.loadClip("http://www.youtube.com/apiplayer", ytplayer); //xml stuff var myXML = new XML(); myXML.ignoreWhite = true; myXML.onLoad = function(){ theVideos = []; whoIsOn = 0; nodes = this.firstChild.childNodes; for(var i=0;i<nodes.length;i++){ theTitles.push(nodes[i].childNodes[0].firstChild.nodeValue); theVideos.push(nodes[i].childNodes[1].firstChild.nodeValue); theDetails.push(nodes[i].childNodes[2].firstChild.nodeValue); } loadMenu(); if(_root.autoplay != "false"){ loadInterval2 = setInterval(checkPlayerLoaded2, 250); } } if(_root.playlist){ myXML.load(_root.playlist + ".xml"); }else{ myXML.load("mylist.xml"); } var listener:Object = new Object(); listener.tmc = target; listener.onLoadInit = function(mc:MovieClip) { new Tween(mc,"_alpha", Strong.easeOut,0,100,1,true); mc._width = 65; mc._height = 50; }; var loader:MovieClipLoader = new MovieClipLoader(); loader.addListener(listener); overlayBtn.useHandCursor = false; overlayBtn._visible = false; var btnOver; var butArray:Array = new Array(); function loadMenu(){ for (var i:Number=0;i<theTitles.length;i++){ var but:MovieClip = listBox.theList.attachMovie("listItem","listItem"+i,i,{_y:(i*60)}); but.theName.htmlText = theTitles[i]; but.theDescription.htmlText = theDetails[i]; loader.loadClip("http://img.youtube.com/vi/" + theVideos[i] + "/2.jpg", but.theThumbnail); but.i = i; butArray.push(but) if((i & 1) == 0){ var my_colorB1:Color = new Color(but.itemBg); my_colorB1.setRGB(0xF7F7F7); }else{ var my_colorB1:Color = new Color(but.itemBg); my_colorB1.setRGB(0xF1F1F1); } but.onRollOver = function(){ if(_root.rollover_changing_thumbs == "true"){ btnOver = this; thumbInterval = setInterval(thumbTimer, 1000); } } but.onRollOut = but.onReleaseOutside = function(){ if(_root.rollover_changing_thumbs == "true"){ clearInterval(thumbInterval); vTime = 0; } } but.onRelease = function(){ whoIsOn = this.i; beforeStartPlay(); } } } var vTime:Number = 0; function thumbTimer(){ vTime++; switch (vTime) { case 1 : //btnOver.theThumbnail.loadMovie("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/1.jpg"); loader.loadClip("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/1.jpg", btnOver.theThumbnail); break; case 2: //btnOver.theThumbnail.loadMovie("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/2.jpg"); loader.loadClip("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/2.jpg", btnOver.theThumbnail); break; case 3: //btnOver.theThumbnail.loadMovie("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/3.jpg"); loader.loadClip("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/3.jpg", btnOver.theThumbnail); vTime = 0; break; } } function errorItem(){ var my_colorB4:Color = new Color(butArray[whoIsOn].theName); my_colorB4.setRGB(0xFF0000); } function theCurrentItem(){ if(listBox.theList._height > listBox.theMask._height && listBox.dragger._y <= (listBox.theMask._height - listBox.dragger._height)){ listBox.dragger._y = ((listBox.theMask._height-listBox.dragger._height)/100)*((whoIsOn*100)/(nodes.length-1)); } var my_colorB2:Color = new Color(butArray[whoIsOn].itemBg); my_colorB2.setRGB(0xCFE0E9); butArray[whoIsOn].theName.htmlText = "<b>"+theTitles[whoIsOn]+"</b>"; for (var i:Number=0;i<theTitles.length;i++){ if(i != whoIsOn){ butArray[i].theName.htmlText = theTitles[i]; if((butArray[i].i & 1) == 0){ var my_colorB3:Color = new Color(butArray[i].itemBg); my_colorB3.setRGB(0xF7F7F7); }else{ var my_colorB3:Color = new Color(butArray[i].itemBg); my_colorB3.setRGB(0xF1F1F1); } } } } controlButtons.nextBtn.onRelease = function(){ if(shuffle == true){ whoIsOn = Math.floor(Math.random()*(nodes.length-1)); }else{ whoIsOn++; if(whoIsOn >= nodes.length){ whoIsOn = 0; } } beforeStartPlay(); } controlButtons.prevBtn.onRelease = function(){ if(shuffle == true){ whoIsOn = Math.floor(Math.random()*(nodes.length-1)); }else{ whoIsOn--; if(whoIsOn < 0){ whoIsOn = nodes.length-1; } } beforeStartPlay(); } //play - pause controlButtons.playPause.onRollOver = function() { if(this._currentframe == 1) { controlButtons.playPause.gotoAndStop("pauseOver"); } else { controlButtons.playPause.gotoAndStop("playOver"); } } controlButtons.playPause.onRollOut = function() { if(this._currentframe == 10) { controlButtons.playPause.gotoAndStop("pause"); } else { controlButtons.playPause.gotoAndStop("play"); } } controlButtons.playPause.onRelease = function() { if(firstTimePlayed == true){ loadInterval2 = setInterval(checkPlayerLoaded2, 250); } if(this._currentframe == 10) { controlButtons.playPause.gotoAndStop("playOver"); ytplayer.pauseVideo(); }else{ controlButtons.playPause.gotoAndStop("pauseOver"); ytplayer.playVideo(); } } shuffleBtn.onRelease = function(){ if(this._currentframe == 1) { this.gotoAndStop(2); shuffle = true; }else{ this.gotoAndStop(1); shuffle = false; } } repeatBtn.onRelease = function(){ if(this._currentframe == 1) { this.gotoAndStop(2); repeat = true; }else{ this.gotoAndStop(1); repeat = false; } } //progress function videoUpdate(){ if (ytplayer.getDuration() > 0) { progressBar._xscale = (ytplayer.getCurrentTime()/ytplayer.getDuration())*100; scrub._x = Math.floor(progressBar._width+progressBar._x); } else { scrub._x = progressBar._x; } theTime.text = getTimecode(ytplayer.getCurrentTime())+" / "+getTimecode(ytplayer.getDuration()); if(theTime.text == "NaN:NaN / NaN:NaN"){ theTime.text = "00:00 / 00:00"; } } loadBar.onPress = function() { progressBar.onEnterFrame = videoScrub; } loadBar.onRelease = loadBar.onReleaseOutside = function() { delete progressBar.onEnterFrame; } function videoScrub() { var dist:Number = (_xmouse-loadBar._x)/loadBar._width; if(dist < 0){ dist = 0; } if(dist > 1){ dist = 1; } ytplayer.seekTo(Math.floor(ytplayer.getDuration()*dist), true); progressBar._xscale = (dist)*100; scrub._x = Math.floor(progressBar._width+loadBar._x); } scrub._x = loadBar._x; progressBar._xscale = 0; //time code function getTimecode(theTime) { var t:Number = Math.round(theTime); var min:Number = Math.floor(t/60); var sec:Number = t%60; var s:String = ""; if(min < 10) { s += "0"; } if(min >= 1) { s += min.toString(); } else { s += "0"; } s += ":"; if(sec < 10) { s += "0"; s += sec.toString(); } else { s += sec.toString(); } return s; } closeBtn._visible = false; bottomLayout._visible = false; closeBtn.onRelease = function(){ if (Stage["displayState"] != "normal") { Stage["displayState"] = "normal"; } normalScreen(); } bigScreenBtn._visible = false; //delete the above code line if you want to enter full screen mode when you click on the video screen bigScreenBtn.onRelease = function(){ toggleFullScreen(); } //full screen button fsBtn.onRollOver = function() { if(this._currentframe == 1) { this.gotoAndStop("goFsOver"); } else { this.gotoAndStop("backToNormalOver"); } } fsBtn.onRollOut = function() { if(this._currentframe == 10) { this.gotoAndStop("goFs"); } else { this.gotoAndStop("backToNormal"); } } fsBtn.onRelease = function() { if(this._currentframe == 10) { toggleFullScreen(); this.gotoAndStop("backToNormalOver"); } else { toggleFullScreen(); this.gotoAndStop("goFsOver"); } } function toggleFullScreen(){ if (Stage["displayState"] == "normal") { Stage["displayState"] = "fullScreen"; fullScreen(); }else{ normalScreen(); Stage["displayState"] = "normal"; } } function fullScreen(){ loadBar._x = 106; loadBar._y = Stage.height - 23; loadBar.loadBarIn._width = Stage.width - 241; loadBar.loadBarBg._width = Stage.width - 240; progressBar._x = loadBar._x + .5; progressBar._y = loadBar._y + .5; progressBar.progressBarIn._width = loadBar.loadBarIn._width; scrub._y = progressBar._y - 4; controlButtons._x = 10; controlButtons._y = Stage.height - 37; overlayBtn._visible = true; closeBtn._visible = true; ytplayer._x = 0; ytplayer._y = 0; ytplayer.setSize(Stage.width, Stage.height-42); closeBtn._x = Stage.width-34; closeBtn._y = Stage.height-30; fsBtn._x = Stage.width - 64; fsBtn._y = closeBtn._y; volumeMc._x = Stage.width-124; volumeMc._y = Stage.height-28; } function normalScreen(){ fsBtn.gotoAndStop("goFs"); loadBar._x = 112; loadBar._y = 372; loadBar.loadBarIn._width = 250; loadBar.loadBarBg._width = 251; progressBar._x = loadBar._x + .5; progressBar._y = loadBar._y + .5; progressBar.progressBarIn._width = loadBar.loadBarIn._width; scrub._y = loadBar._y - 4; controlButtons._x = 15; controlButtons._y = 358; fsBtn._visible = true; closeBtn._visible = false; closeBtn._x = 331; closeBtn._y = 274; fsBtn._x = 443; fsBtn._y = 365; ytplayer.setSize(456, 340); ytplayer._x = 10; ytplayer._y = 10; bottomLayout._visible = true; overlayBtn._visible = true; overlayBtn._width = 362; overlayBtn._height = 308; volumeMc._x = 381; volumeMc._y = 367; } normalScreen() var stageResize:Object = new Object(); stageResize.onResize = function(){ if (Stage["displayState"] == "normal") { normalScreen(); } } Stage.addListener(stageResize); //volume code ytplayer.setVolume(dist); volumeMc.volScrub._xscale = 70; volumeMc.volBottom.onPress = function() { adjustSound(); this.onMouseMove = adjustSound; } volumeMc.volBottom.onRelease = volumeMc.volBottom.onReleaseOutside = function() { delete this.onMouseMove; } function adjustSound() { var dist:Number = Math.floor(((volumeMc._xmouse-volumeMc.volBottom._x)/volumeMc.volBottom._width)*100); if(dist >= 0 && dist <= 100) { volumeMc.volScrub._xscale = dist; ytplayer.setVolume(dist); } } function theQuality(){ var qualityLevels:Array = ytplayer.getAvailableQualityLevels(); // qualityLevels may be undefined if the API function does not exist, // in which case this conditional is false if (qualityLevels.length > 1) { var highestQuality:String = qualityLevels[0]; trace(highestQuality) if (highestQuality == "hd720") { // Brand quality toggle button as HD. ytplayer.setPlaybackQuality("hd720"); //trace(ytplayer.getPlaybackQuality()) } else { // Brand quality toggle button as HQ. // The highest available quality is shown, but it is not HD video. ytplayer.setPlaybackQuality("large"); } var quality:String = getPlaybackQuality(); if (quality == 'small' || quality == 'medium') { // The user is not watching the highest quality available // can can toggle to a higher quality. } else { // The user is watching the highest quality available // and can toggle to a lower quality. } } else { // Hide the toggle button because there is no current video or // there is only one quality available. } } OBS.: Já tentei o stopAllSounds (); mas só funciona offline, qundo coloco na internet continua a mesma coisa. Obrigado Compartilhar este post Link para o post Compartilhar em outros sites
Donando 1 Denunciar post Postado Dezembro 27, 2010 Já tive um problema desse uma vez. A solução foi criar a função do volume ficar = 0. abs Compartilhar este post Link para o post Compartilhar em outros sites
wrongdoer 0 Denunciar post Postado Dezembro 28, 2010 Já tive um problema desse uma vez. A solução foi criar a função do volume ficar = 0. abs exatamente como você fez isso, teria como postar o código? Valew Compartilhar este post Link para o post Compartilhar em outros sites
Donando 1 Denunciar post Postado Janeiro 21, 2011 você pode tentar o stopAllSounds(); mas no seu caso talvez funcione melhor var som:Sound = new Sound(); som.setVolume(0); pensei que pode fazer uma função, talvez seja outro caminho. var som:Sound = new Sound(); som.onSoundComplete = function() { som.setVolume(0); }; espero que ajude. abs Compartilhar este post Link para o post Compartilhar em outros sites