1. ¡OFERTA! con cupón "DIRVPS": hosting por $0,01 y también VPS Linux y Windows por $0,01 el primer mes por Interserver ← publi
    Descartar aviso
Descartar aviso
Al usar este sitio web, aceptas que nosotros y nuestros socios podamos establecer cookies para fines tales como personalizar el contenido y la publicidad. Más información.

AYUdA CON EL CODIGO - REPROD MP3EN FLASH

Tema en 'Imagen Digital y Video' iniciado por male_massa, 24 Feb 2010.

  1. male_massa

    male_massa Nuevo usuario

    hola, tengo el siguiente codigo, de una plantilla, y no logro que me reproduzca la siguiente pista cuando termina la primera. si lo hace cuando actualizo el navegador. pero quisiera que cuando estas navegando la pagina termine una cancion y comience otra.
    GRACIAS POR LA AYUDA!

    */
    // lets start by calling our config file
    // create new xml object and load config.xml
    var config:XML = new XML();
    config.ignoreWhite = true;
    // once the xml is loaded fire the loadConfig function
    config.onLoad = loadConfig;
    config.load("xml/musicPlayer/config.xml");
    // on load of xml
    function loadConfig(success:Boolean):Void {
    if (success) {
    // get our xml start point
    var all:XMLNode = config.firstChild;
    // retrieve all xml options
    usePhp = Boolean(all.childNodes[0].firstChild.nodeValue);
    buffTime = Number(all.childNodes[1].firstChild.nodeValue);
    recordVol = all.childNodes[2].firstChild.nodeValue;
    playerAlpha = Number(all.childNodes[3].firstChild.nodeValue);
    startCut = Number(all.childNodes[4].firstChild.nodeValue);
    endCut = Number(all.childNodes[5].firstChild.nodeValue);
    fadeInSpeed = Number(all.childNodes[6].firstChild.nodeValue);
    fadeOutSpeed = Number(all.childNodes[7].firstChild.nodeValue);
    bufferingMsg = all.childNodes[8].firstChild.nodeValue;
    nowPlayingMsg = all.childNodes[9].firstChild.nodeValue;
    offMsg = all.childNodes[10].firstChild.nodeValue;
    msgTextColor = Number(all.childNodes[11].firstChild.nodeValue);
    // now our config has loaded let build the player
    buildMusicPlayer();
    } else {
    trace("XML NOT LOADED");
    }
    }
    // import needed classes
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    // lets hide everything until our config has loaded
    player._visible = false;
    function buildMusicPlayer() {
    // we can now show the player and set its defaults
    player._visible = true;
    scope = this;
    player.status.autoSize = "LEFT";
    player.status.textColor = msgTextColor;
    player.status.text = bufferingMsg;
    player.playStop.playBtn._alpha = 0;
    // if we are using the php lets load it
    if (usePhp == true) {
    buildMp3 = new XML();
    buildMp3.load("php/buildMusicPlayer.php");
    }
    // create new xml object and load music.xml
    var music:XML = new XML();
    music.ignoreWhite = true;
    // once the xml is loaded fire the buildPosts function
    music.onLoad = buildposts;
    music.load("xml/musicPlayer/songs.xml");
    function buildposts(success:Boolean):Void {
    if (success) {
    // send width of player to our main movie, so we can position it accurately
    _parent._parent.musicWidth = scope._width;
    _parent._parent.setPostions();
    // set up arrays to store song details
    songPath = [];
    songName = [];
    // get xml start point
    var allXML:XMLNode = music.firstChild;
    // get song total
    songTotal = allXML.childNodes.length;
    // if there is only one song we need to bypass the random number generation
    if (songTotal>0) {
    var randNo:Number = Math.floor(Math.random()*songTotal);
    } else {
    randNo = 0;
    }
    // create new shared object to store previous random number
    // we do this so the same song can`t be played twice in a row
    so = SharedObject.getLocal("num");
    //if shared object equals the new random number change random number.
    if ((so.data["num"] == randNo)) {
    if (so.data["num"]>1) {
    randNo--;
    } else {
    randNo++;
    }
    }
    // set new num to store in cookie.
    so.data["num"] = randNo;
    // extra each path and name and store in our arrays
    for (i=0; i<songTotal; i++) {
    songPath = allXML.childNodes.attributes.src;
    songName = allXML.childNodes.childNodes[0];
    }
    // load our choosen song
    loadSound(songPath[randNo]);
    }
    function loadSound(mp3) {
    // set buffer time
    _soundbuftime = buffTime;
    // ceate new sound
    snd = new Sound(scope);
    // set streaming to true
    snd.loadSound(mp3, true);
    // set volume to 0
    obj = new Object();
    obj.vol = 0;
    snd.setVolume(obj.vol);
    snd.onLoad = function() {
    snd.start();
    // this where our song will now end
    newEndPoint = snd.duration-endCut;
    snd.setVolume(obj.vol);
    };
    }
    scope.onEnterFrame = function() {
    // get amount of song loaded
    var amountLoaded = snd.getBytesLoaded()/snd.getBytesTotal();
    // if loaded
    if (amountLoaded == 1) {
    // if we are going to store the on/off user choice
    if (recordVol == "true") {
    // cookie for storing volume level
    so = SharedObject.getLocal("volume");
    //if shared object has data already in it
    if ((so.data["level"] != null)) {
    // get saved level and fade in music
    volStart = so.data["level"];
    fadeSound(0, volStart, fadeInSpeed);
    // if on, set defaults
    if (volStart == 100) {
    player.status.text = nowPlayingMsg+" "+songName[randNo];
    isPlaying = true;
    player.playStop.stopBtn._alpha = 100;
    player.playStop.playBtn._alpha = 0;
    // else set "off" defaults
    } else {
    player.status.text = offMsg;
    isPlaying = false;
    player.playStop.stopBtn._alpha = 0;
    player.playStop.playBtn._alpha = 100;
    }
    }
    // else if no cookie found set the "on" defaults
    if ((so.data["level"] == null)) {
    fadeSound(0, 100, fadeInSpeed);
    player.status.text = nowPlayingMsg+" "+songName[randNo];
    isPlaying = true;
    player.playStop.stopBtn._alpha = 100;
    player.playStop.playBtn._alpha = 0;
    }
    }
    /* let grab the width the player now we have all the text in and update our main
    movie positioning code.*/
    _parent._parent.musicWidth = scope._width;
    _parent._parent.setPostions();
    // now we don`t need this onEnterframe so lets kill it
    delete this.onEnterFrame;
    }
    };
    // this function checks to see if the loop has reached it end (minus our endCut point)
    // when the end is found, we go back to the start of the track (plus our startCut)
    player.onEnterFrame = function() {
    if (snd.position>newEndPoint) {
    snd.stop();
    snd.start(startCut/1000);
    }
    };
    // set up sound object
    // set default alpha level of player (everything)
    player._alpha = playerAlpha;
    // mute button
    player.onRelease = function():Void {
    faderSound.stop();
    // if player is off
    if (isPlaying == false) {
    // fade in and set "on" state
    fadeSound(obj.vol, 100, fadeInSpeed);
    isPlaying = true;
    player.status.text = nowPlayingMsg+" "+songName[randNo];
    player.playStop.stopBtn._alpha = 100;
    player.playStop.playBtn._alpha = 0;
    // record volume to cookie
    so.data["level"] = 100;
    } else {
    // fade out and set "off" state
    fadeSound(obj.vol, 0, fadeOutSpeed);
    isPlaying = false;
    player.status.text = offMsg;
    player.playStop.stopBtn._alpha = 0;
    player.playStop.playBtn._alpha = 100;
    so.data["level"] = 0;
    }
    // scale hitzone to text size
    player.hitzone._width = player.status.textWidth;
    // update main movie position code with new width
    _parent._parent.musicWidth = player._width;
    _parent._parent.setPostions();
    };
    // fade up on player mouse over
    player.onRollOver = function():Void {
    fade(this, this._alpha, 100, 1, "_alpha");
    };
    player.onRollOut = function():Void {
    fade(this, this._alpha, playerAlpha, 1, "_alpha");
    };
    }
    }
    // fade sound function
    function fadeSound(startVal, endVal, speed):Void {
    faderSound = new Tween(obj, "vol", Strong.easeOut, startVal, endVal, speed, true);
    faderSound.onMotionChanged = function() {
    snd.setVolume(Math.round(obj.vol));
    };
    }
    // fade mc`s
    function fade(who:MovieClip, startvalue:Number, endvalue:Number, y_speed:Number, prop:String):Void {
    var fader:Tween = new Tween(who, prop, Strong.easeOut, startvalue, endvalue, y_speed, true);
    }
     
  2.  


Alojamiento web, Hosting Reseller, Servidores Dedicados - All in Hosting


    
    
    
    
Blog · Sitios amigos: GuiaHosting · Unidominios · Interalta ·