Ciao!
Con questo codice creo un lettore mp3...
Vorrei una cosa semplice. NON far partire il primo mp3 in automatico. Vorrei he la musica partisse quando premo play...
Ho provato a modificare musicPlay = true; in "false" ma nulla da fare.
Potreste aiutarmi??
Codice PHP:
musicPlay = true;
songList = new Array();
playListFile = "playlist";
track = 1;
newSong = false;
playlistshow.text = playListFile + ".xml";
playList = new XML();
playList.ignoreWhite = true;
playList.onLoad = function (success)
{
if (!success)
{
playlistshow.text = "file non trovato";
return(undefined);
} // 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 if
}
else if (!musicPlay)
{
progress.text = "00:00 / 00:00";
} // end 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");
};