Visualizzazione dei risultati da 1 a 4 su 4

Discussione: riproduzione file mp3

  1. #1

    riproduzione file mp3

    Salve a tutti, sto facendo un ActionScript, per riprodurre i file audio, per ora ho aggiunto 2 bottoni, il playPause (se lo si clicca va in pausa e se lo si riclicca fa in play) e il bottone next, per cambiare canzone.... il broblema sorge quando testo il filmato, il rollover del tasto next non funziona e non so come fare a risolvere il problema.

    Qui di seguito trovate l'ActionScript, mentre qui trovate il filmato di prova...

    // Setup dello script
    var s:Sound = new Sound();
    s.onSoundComplete = playSong;
    s.setVolume(75);

    // Array delle canzoni
    var sa:Array = new Array();

    // Canzone in riproduzione
    var cps:Number = -1;

    // Posizione della musica
    var pos:Number;

    // Load delle canzoni dal file XML
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function()
    {
    var nodes:Array = this.firstChild.childNodes;
    for(var i=0; i<nodes.length; i++)
    {
    sa.push(nodes[i].attributes.url);
    }
    playSong();
    }

    xml.load("songs.xml");

    // Play dei file MP3
    function playSong():Void
    {
    s = new Sound();
    if(cps == sa.length -1)
    {
    cps = 0;
    s.loadSound(sa[cps], true);
    }
    else
    {
    s.loadSound(sa[++cps], true);
    }
    playPause.gotoAndStop("pause")
    }

    // Musica in pausa
    function pauseIt():Void
    {
    pos = s.position;
    s.stop();
    }

    function unPauseIt():Void
    {
    s.start(pos/1000);
    }

    // Controlli della musica

    // Play/Pause della musica
    playPause.onRollOver = function()
    {
    if(this._currentframe == 1) this.gotoAndStop("pauseOver");
    else this.gotoAndStop("playOver");
    }

    playPause.onRollOut = playPause.onReleaseOutside = function()
    {
    if(this._currentframe == 10) this.gotoAndStop("pause");
    else this.gotoAndStop("play");
    }

    playPause.onRelease = function ()
    {
    if(this._currentframe == 10)
    {
    this.gotoAndStop("playOver");
    this._parent.pauseIt();
    }
    else
    {
    this.gotoAndStop("pauseOver");
    this._parent.unPauseIt();
    }
    }

    // Bottone Next
    next.onRollOver = function()
    {
    next.gotoAndStop("nextOver");
    }

    next.onRollOut = next.onReleaseOutside = function()
    {
    next.gotoAndStop("next");
    }

    next.onRelease = function()
    {
    this._parent.playSong();
    }



    PS ditemi se provando lo script sentite la musica. Grazie
    La rovina del mondo sara' l'indifferenza. Ma chi se ne frega!!

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,628

    Re:

    A me così funziona:


    variabile = 1;
    //Controlla quale brano caricare
    timer = 0;
    //Controlla la pausa accollandosi il valore di suono.position
    interruttore = false;
    //Interruttore per far scrvere il testo brano.
    suono = new Sound();
    esegui.enabled = false;
    //Imposto a spento l'interruttore play
    function suonare() {
    interruttore = true;
    suono.attachSound(variabile);
    suono.start(timer, 1);
    }
    esegui.onRelease = function() {
    suonare();
    esegui.enabled = false;
    ferma.enabled=true;
    };
    ferma.onRelease = function() {
    suono.stop();
    interruttore = false;
    esegui.enabled = true;
    timer = 0;
    };
    pausa.onRelease = function() {
    timer = (suono.position)/1000;
    suono.stop();
    esegui.enabled = true;
    ferma.enabled=false;
    };
    avanti.onRelease = function() {
    suono.stop();
    timer = 0;
    if (variabile<3) {
    variabile += 1;
    } else {
    variabile = 1;
    }
    suonare();
    interruttore = true;
    esegui.enabled = false;
    ferma.enabled=true;
    };
    indietro.onRelease = function() {
    suono.stop();
    timer = 0;
    if (variabile>1) {
    variabile -= 1;
    } else {
    variabile = 3;
    }
    suonare();
    interruttore = true;
    esegui.enabled = false;
    ferma.enabled=true;
    };
    controllo_volume.freccia.onPress = function() {
    this.startDrag(false, -5, 10, 95, 10);
    };
    controllo_volume.freccia.onRelease = function() {
    this.stopDrag();
    };
    bilanciamento.freccia_bilanciamento.onPress = function() {
    this.startDrag(false, -55, 10, 45, 10);
    };
    bilanciamento.freccia_bilanciamento.onRelease = function() {
    this.stopDrag();
    };
    onEnterFrame = function () {
    valore_volume = controllo_volume.freccia._x+5;
    suono.setVolume(valore_volume);
    testo_volume.text = "Volume impostato al "+valore_volume+"%";
    valore_bilanciamento = (bilanciamento.freccia_bilanciamento._x+5)*2;
    suono.setPan(valore_bilanciamento);
    if (interruttore == true) {
    brano.text = "Il brano in esecuzione è il numero "+variabile;
    } else {
    brano.text = "Nessun brano in esecuzione";
    }
    suono.onSoundComplete = function() {
    esegui.enabled = true;
    ferma.enabled = false;
    interruttore=false;
    };
    };
    suonare();


    Tieni presente che qui c'è anche il controllo volume e bilanciamento.....

  3. #3
    Io sto seguendo un tutorial e sto impazzendo xke non capisco come continuarlo, a me lo script sembra giusto...x quello ke ne capisco... tu vedi qualche errore?
    La rovina del mondo sara' l'indifferenza. Ma chi se ne frega!!

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,628

    Re:

    Non mi chiedere di studiare il tuo script...
    Io so che con quello mio funziona....

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.