- Home
- Categorie
- Digital Marketing
- Grafica, Visual Design & UX
- Loop infinito Mp3
-
Loop infinito Mp3
Salve a tutti. Sto facendo un sito ad alcuni amici musicisti , ho inserito un lettore Play - Stop però non riesco a farlo loopare all'infinito.
questo è il codice del lettore
volume_mc.slider_mc.useHandCursor = false;
var musicReq:URLRequest;
var music:Sound = new Sound();
var sc:SoundChannel;
var currentSound:Sound = music;
var pos:Number;var xml:XML;
var songlist:XMLList;
var currentIndex:Number = 0;var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, whenLoaded);function whenLoaded(e:Event):void
{
xml = new XML(e.target.data);
songlist = xml.song;
musicReq = new URLRequest(songlist[0].url);
music.load(musicReq);
sc = music.play();
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}loader.load(new URLRequest("jukebox.xml"));
play_btn.addEventListener(MouseEvent.CLICK,playSong);
stop_btn.addEventListener(MouseEvent.CLICK,stopSong);function nextSong(e:Event):void
{
if (currentIndex < (songlist.length() - 1))
{
currentIndex++;
}
else
{
currentIndex = 0;
}}
function playSong(e:Event):void
{
sc = currentSound.play(pos);
}function stopSong(e:Event):void
{
sc.stop();
pos = 0;
}Grazie per l'aiuto