Visualizzazione dei risultati da 1 a 8 su 8

Discussione: Player audio e xml

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    33

    Player audio e xml

    Ciao,
    sono alle prese con questo problema:
    ho un player audio che prende i file mp3 da un .xml.
    Ho inserito questo player.swf nel mio filmato principale, dapprima richiamandolo con questo script in un clip filmato vuoto con istanza player:

    loadMovie("player.swf", player);

    ma non me lo caricava...
    poi ho provato ad inserire il frame contenente il player direttamente nel filmato principale.
    Il problema è che eseguendo la prova del filmato da flash, il player non mi carica il file audio dal .xml.
    A questo punto ho pensato che bisognava fare una prova su server locale,altrimenti non avrebbe mai letto il file xml.
    Quindi pubblico il filmato principale contenente il player e metto il file html generato nella cartella del server assieme al file .swf e il file .xml.
    Eseguo il file html, e neanche in questo caso il player mi carica il file audio.
    Non riesco a capire il motivo....

    vi allego lo script del player:

    nel clip che contiene il player c'e:

    onClipEvent (initialize)
    {
    playListFile = "default";
    }

    e per il player ho questo codice:

    musicPlay = true;
    songList = new Array();
    playListFile = "default";
    track = 1;
    newSong = false;
    playlistshow.text = playListFile + ".xml";
    playList = new XML();
    playList.ignoreWhite = true;
    playList.onLoad = function (success)
    {
    if (!success)
    {
    playlistshow.text = "file not found";
    return;
    } // end if
    n = playList.firstChild.childNodes;
    var s = 0;
    while (s < n.length)
    {
    songList[s] = n[s].attributes.file;
    ++s;
    } // end while
    playlistshow.text = playListFile + ".xml";
    holder.music = new Sound();
    holder.music.loadSound(songList[track - 1], true);
    holder.music.onSoundComplete = function ()
    {
    track = track + 1;
    if (track > songList.length)
    {
    track = 1;
    } // end if
    newSong = true;
    };
    slider.onEnterFrame = function ()
    {
    vol = Math.round((slider._x - slidebar._x) / (slidebar._width / 100));
    holder.music.setVolume(vol);
    };
    slider.btn.onPress = function ()
    {
    slider.startDrag(false, slidebar._x, slidebar._y, slidebar._x + slidebar._width, slidebar._y);
    };
    slider.btn.onRelease = function ()
    {
    slider.stopDrag();
    };
    };
    playList.load(playListFile + ".xml");
    holder.onEnterFrame = function ()
    {
    if (musicPlay)
    {
    pos = Math.round(holder.music.position);
    dur = Math.round(holder.music.duration);
    mins_played = Math.floor(pos / 1000 / 60);
    secs_played = Math.round(pos / 1000) - mins_played * 60;
    mins_tot = Math.floor(dur / 1000 / 60);
    secs_tot = Math.round(dur / 1000) - mins_tot * 60;
    if (pos != 0 && dur != 0)
    {
    if (secs_played > 59)
    {
    mins_played = mins_played + 1;
    } // end if
    if (secs_tot > 59)
    {
    mins_tot = mins_tot + 1;
    } // end if
    if (secs_tot > 59)
    {
    secs_tot = 0;
    } // end if
    if (secs_played > 59)
    {
    secs_played = 0;
    } // end if
    if (secs_tot < 10)
    {
    secs_tot = "0" + secs_tot;
    } // end if
    if (secs_played < 10)
    {
    secs_played = "0" + secs_played;
    } // end if
    if (mins_played < 10)
    {
    mins_played = "0" + mins_played;
    } // end if
    if (mins_tot < 10)
    {
    mins_tot = "0" + mins_tot;
    } // end if
    progress.text = mins_played + ":" + secs_played + " / " + mins_tot + ":" + secs_tot;
    }
    else if (pos == 0 && dur == 0)
    {
    progress.text = "00:00 / 00:00";
    } // end else if
    }
    else if (!musicPlay)
    {
    progress.text = "00:00 / 00:00";
    } // end else if
    if (newSong)
    {
    holder.music.stop();
    holder.music = new Sound();
    holder.music.loadSound(songList[track - 1], true);
    holder.music.onSoundComplete = function ()
    {
    track = track + 1;
    if (track > songList.length)
    {
    track = 1;
    } // end if
    newSong = true;
    };
    newSong = false;
    } // end if
    title.text = playList.firstChild.childNodes[track - 1].attributes.title;
    artist.text = playList.firstChild.childNodes[track - 1].attributes.artist;
    album.text = playList.firstChild.childNodes[track - 1].attributes.album;
    };
    onbtn.onRelease = function ()
    {
    track = track + 1;
    if (track > songList.length)
    {
    track = 1;
    } // end if
    if (musicPlay)
    {
    newSong = true;
    } // end if
    };
    onbtn.onReleaseOutside = function ()
    {
    track = track + 1;
    if (track > songList.length)
    {
    track = 1;
    } // end if
    if (musicPlay)
    {
    newSong = true;
    } // end if
    skipon.gotoAndStop("up");
    };
    backbtn.onRelease = function ()
    {
    track = track - 1;
    if (track < 1)
    {
    track = songList.length;
    } // end if
    if (musicPlay)
    {
    newSong = true;
    } // end if
    };
    backbtn.onReleaseOutside = function ()
    {
    track = track - 1;
    if (track < 1)
    {
    track = songList.length;
    } // end if
    if (musicPlay)
    {
    newSong = true;
    } // end if
    skipback.gotoAndStop("up");
    };
    playbtn.onRelease = function ()
    {
    if (!musicPlay)
    {
    holder.music = new Sound();
    holder.music.loadSound(songList[track - 1], true);
    holder.music.onSoundComplete = function ()
    {
    track = track + 1;
    if (track > songList.length)
    {
    track = 1;
    } // end if
    newSong = true;
    };
    musicPlay = true;
    } // end if
    };
    playbtn.onReleaseOutside = function ()
    {
    if (!musicPlay)
    {
    holder.music = new Sound();
    holder.music.loadSound(songList[track - 1], true);
    holder.music.onSoundComplete = function ()
    {
    track = track + 1;
    if (track > songList.length)
    {
    track = 1;
    } // end if
    newSong = true;
    };
    musicPlay = true;
    } // end if
    playclip.gotoAndStop("up");
    };
    stopbtn.onRelease = function ()
    {
    if (musicPlay)
    {
    holder.music.stop();
    musicPlay = false;
    } // end if
    };
    stopbtn.onReleaseOutside = function ()
    {
    if (musicPlay)
    {
    holder.music.stop();
    musicPlay = false;
    } // end if
    stopclip.gotoAndStop("up");
    };
    onbtn.onRollOver = function ()
    {
    skipon.gotoAndStop("down");
    };
    onbtn.onRollOut = function ()
    {
    skipon.gotoAndStop("up");
    };
    backbtn.onRollOver = function ()
    {
    skipback.gotoAndStop("down");
    };
    backbtn.onRollOut = function ()
    {
    skipback.gotoAndStop("up");
    };
    playbtn.onRollOver = function ()
    {
    playclip.gotoAndStop("down");
    };
    playbtn.onRollOut = function ()
    {
    playclip.gotoAndStop("up");
    };
    stopbtn.onRollOver = function ()
    {
    stopclip.gotoAndStop("down");
    };
    stopbtn.onRollOut = function ()
    {
    stopclip.gotoAndStop("up");
    };

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    apparte lo script che ci vuole mezzora per leggerlo e capirlo, non hai detto una cosa, singolarmente (cioè senza caricarlo da nessuna parte) il player funziona?

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    33
    No, non funziona neanche da solo...

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da DASTY78
    No, non funziona neanche da solo...
    allora è un bel problema,
    trovare un errore in quel botto di codice non è facile, soprattutto quando non si ha il file a disposizione,
    il codice penso che non l'abbia scritto tu no?!

    ps. ma non è che magari è solo sbagliata la compilazione del file .xml ?

    pps. hi tenuto conto dei nomi e percorsi dei file??

  5. #5
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    33
    Ovviamente il codice non l'ho scritto io, il file xml l'ho verificato ed è corretto.
    L'errore che mi esce è: Error opening URL.
    Ma io il file audio l'ho inserito nella stessa certella del file del player...ho fatto bene?

  6. #6
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da DASTY78
    L'errore che mi esce è: Error opening URL.
    questo però prima non l'hai detto, io pensavo che non ti riproducesse il suono ma che fosse corretta la posizione ecc... è un problema di percorsi, bisognerebbe risalire alla struttura originaria del player per capire dove sia l'errore

  7. #7
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    33
    Grazie mille x l'aiuto ma a questo punto credo che abbandono e mi faccio un piccolo player con codice semplice scritto da me..forse è la soluzione migliore

  8. #8
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da DASTY78
    Grazie mille x l'aiuto ma a questo punto credo che abbandono e mi faccio un piccolo player con codice semplice scritto da me..forse è la soluzione migliore
    credo anch'io, il codice che hai postato ha parecchi "lati oscuri", mi sembra un po' troppo ridondante, alla fine con i metodi di XML() e Sound() te la cavi egregiamente con 1/3 delle righe che hai riportato

    buon lavoro

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 © 2025 vBulletin Solutions, Inc. All rights reserved.