• User Attivo

    problema con autoplay

    salve a tutti,
    dunque, ho scaricato ( non ricordo da dove) un riproduttore di filmati in flash che carica i dati via xml.
    funziona benissimo, solo che vorrei evitare che appena si apre l'swf partisse in automatico il primo video.
    Ho cercato di capire dove intervenire sul codice ma non ne vengo a capo.. qualcuno mi può aiutare?
    grazie 🙂

    var nDownload:Number;
    var nPlayback:Number;
    var totalLength:Number;
    var currentVideo:Number = 0;
    var totalVideos:Number;
    var scrubSpeed:Number = 5;
    var paused:Boolean = false;
    var movieEnded:Boolean;
    var aVideos:Array = new Array();
    var videoXML:XML = new XML();
    videoXML.ignoreWhite = true;
    var rootNode:XMLNode;
    var currNode:XMLNode;
    videoXML.onLoad = function():Void  {
     rootNode = this.firstChild;
     for (var i:Number = 0; i<rootNode.childNodes.length; i++) {
      currNode = rootNode.childNodes*;
      aVideos.push({source:currNode.attributes["source"], title:currNode.attributes["titolo"], title2:currNode.attributes["titolo2"], author:currNode.attributes["autore"], year:currNode.attributes["anno"]});
     }
     totalVideos = aVideos.length;
     populateList();
    };
    videoXML.load("videos.xml");
    var cList:Object = mcTab.mcPlaylist.cList;
    cList.vScrollPolicy = "auto";
    var listListener:Object = new Object();
    cList.addEventListener("change", listListener);
    listListener.change = function() {
     var index:Number = cList.selectedIndex;
     currentVideo = index;
     populateFields(index);
     playVideo(aVideos[index].source);
    };
    function populateList():Void {
     for (var i:Number = 0; i<totalVideos; i++) {
      cList.addItem(aVideos*.title2);
     }
     cList.selectedIndex = currentVideo;
     populateFields(0);
     playVideo(aVideos[0].source);
    }
    function populateFields(index:Number):Void {
     tTitle.text = aVideos[index].title;
     tYear.text = aVideos[index].year;
     tAuthor.text = aVideos[index].author;
    }
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    ns.setBufferTime(5);
    mcVideo.oVideo.attachVideo(ns);
    function playVideo(video:String):Void {
     movieEnded = false;
     mcBuffer._visible = true;
     clearIntervals();
     ns.play(video);
     nDownload = setInterval(downloadProgress, 1000/24);
     nPlayback = setInterval(playback, 1000/24);
    }
    ns.onStatus = function(oInfo:Object):Void  {
     //trace(oInfo.code);
     if (oInfo.code == "NetStream.Play.Start") {
     }
     if (oInfo.code == "NetStream.Play.Stop") {
      //trace("movie ended");
      clearInterval(nPlayback);
      movieEnded = true;
      mcBuffer._visible = false;
     }
     if (oInfo.code == "NetStream.Play.StreamNotFound") {
      //trace("movie cannot be found");
     }
     if (oInfo.code == "NetStream.Buffer.Full") {
      mcBuffer._visible = false;
     }
     if (oInfo.code == "NetStream.Buffer.Empty" && !movieEnded) {
      //trace("buffer empty");
      mcBuffer._visible = true;
      var timeRemaining:Number = totalLength-ns.time;
      if (timeRemaining<ns.bufferTime) {
       ns.setBufferTime(timeRemaining);
      }
     }
    };
    ns["onMetaData"] = function (oInfo:Object):Void {
     totalLength = oInfo.duration;
    };
    //trace(ns.bufferTime);
    var nBytesLoaded:Number;
    var nBytesTotal:Number;
    var percentageLoaded:Number;
    function downloadProgress():Void {
     nBytesLoaded = ns.bytesLoaded;
     nBytesTotal = ns.bytesTotal;
     percentageLoaded = nBytesLoaded/nBytesTotal*100;
     mcProgressBar.mcDownloadBar._xscale = percentageLoaded;
     if (percentageLoaded == 100) {
      clearInterval(nDownload);
     }
    }
    var percentPlayed:Number;
    function playback():Void {
     percentPlayed = ns.time/totalLength*100;
     mcProgressBar.mcPlayhead._x = percentPlayed*1.5;
    }
    mcControls.mcPlay.onRelease = function():Void  {
     if (paused) {
      ns.pause();
      paused = !paused;
     }
    };
    mcControls.mcNext.onRelease = function():Void  {
     currentVideo++;
     if (currentVideo == totalVideos) {
      currentVideo = 0;
     }
     cList.selectedIndex = currentVideo;
     populateFields(currentVideo);
     playVideo(aVideos[currentVideo].source);
    };
    mcControls.mcPrevious.onRelease = function():Void  {
     currentVideo--;
     if (currentVideo<0) {
      currentVideo = totalVideos-1;
     }
     cList.selectedIndex = currentVideo;
     populateFields(currentVideo);
     playVideo(aVideos[currentVideo].source);
    };
    mcControls.mcForward.onPress = function():Void  {
     this.onEnterFrame = function():Void  {
      ns.seek(ns.time+scrubSpeed);
     };
    };
    mcControls.mcForward.onRelease = function():Void  {
     delete this.onEnterFrame;
    };
    mcControls.mcRewind.onPress = function():Void  {
     this.onEnterFrame = function():Void  {
      ns.seek(ns.time-scrubSpeed);
     };
    };
    mcControls.mcRewind.onRelease = function():Void  {
     delete this.onEnterFrame;
    };
    mcControls.mcPause.onRelease = function():Void  {
     ns.pause();
     paused = !paused;
    };
    mcProgressBar.mcPlayhead.onPress = function():Void  {
     clearInterval(nPlayback);
     this.startDrag(true, 0, this._y, mcProgressBar.mcDownloadBar._xscale*1.5, this._y);
     this.onEnterFrame = function():Void  {
      ns.seek(this._x*totalLength/150);
     };
    };
    mcProgressBar.mcPlayhead.onRelease = function():Void  {
     this.stopDrag();
     delete this.onEnterFrame;
     nPlayback = setInterval(playback, 1000/24);
    };
    mcProgressBar.mcPlayhead.onReleaseOutside = mcProgressBar.mcPlayhead.onRelease;
    var flvSound_mc:MovieClip = _root.createEmptyMovieClip("flvSound_mc", _root.getNextHighestDepth());
    flvSound_mc.attachAudio(ns);
    var soundHolder_sound:Sound = new Sound(flvSound_mc);
    soundHolder_sound.setVolume(100);
    mcMute.onRelease = function():Void  {
     if (soundHolder_sound.getVolume() == 100) {
      soundHolder_sound.setVolume(0);
      mcMute.gotoAndStop(2);
     } else {
      soundHolder_sound.setVolume(100);
      mcMute.gotoAndStop(1);
     }
    };
    mcTip.tText.autoSize = "left";
    mcControls.mcPlay.onRollOver = toolTip;
    mcControls.mcForward.onRollOver = toolTip;
    mcControls.mcRewind.onRollOver = toolTip;
    mcControls.mcNext.onRollOver = toolTip;
    mcControls.mcPrevious.onRollOver = toolTip;
    mcControls.mcPause.onRollOver = toolTip;
    mcControls.mcPlay.onRollOut = resetTip;
    mcControls.mcRewind.onRollOut = resetTip;
    mcControls.mcForward.onRollOut = resetTip;
    mcControls.mcNext.onRollOut = resetTip;
    mcControls.mcPrevious.onRollOut = resetTip;
    mcControls.mcPause.onRollOut = resetTip;
    mcControls.mcPlay.onRollOut = resetTip;
    function toolTip():Void {
     switch (this) {
     case _level0.mcControls.mcNext :
      mcTip.tTip.text = "next";
      break;
     case _level0.mcControls.mcPrevious :
      mcTip.tTip.text = "previous";
      break;
     case _level0.mcControls.mcForward :
      mcTip.tTip.text = "forward";
      break;
     case _level0.mcControls.mcRewind :
      mcTip.tTip.text = "rewind";
      break;
     case _level0.mcControls.mcPlay :
      mcTip.tTip.text = "play";
      break;
     case _level0.mcControls.mcPause :
      mcTip.tTip.text = "pause";
      break;
     }
     this.onEnterFrame = function():Void  {
      mcTip._x = _xmouse;
     };
    }
    function resetTip():Void {
     delete this.onEnterFrame;
     mcTip.tTip.text = "";
    }
    mcTab.mcHit.onRollOver = function():Void  {
     mcTab.play();
    };
    function clearIntervals():Void {
     clearInterval(nDownload);
     clearInterval(nPlayback);
    }
    
    

  • Super User

    Ciao claire,
    prova a commentare le righe 39 e 40 🙂