# Can I loop streamed audio?

**URL:** https://forum.kirupa.com/t/can-i-loop-streamed-audio/42763
**Category:** Uncategorized
**Created:** [February 12, 2004, 6:42pm UTC](https://forum.kirupa.com/t/can-i-loop-streamed-audio/42763 "2004-02-12T18:42:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![artane](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@artane](https://forum.kirupa.com/u/artane)
#### Post date: [February 12, 2004, 6:42pm UTC](https://forum.kirupa.com/t/can-i-loop-streamed-audio/42763/1 "2004-02-12T18:42:53Z")

</div>

hey guys,

I’ve designed an audio interface that plays streamed audio files that I have saved as mp3’s on my server. It works great but, when the first song ends, it plays the second song etc. I want it to loop the current song unless the user requests otherwise. What should I add to the following script?

thanks very much,

artane  
…

\_global.songs = new Array();  
\_global.playing = “no”;  
\_global.currentSong = 1;  
\_global.songs[1] = “song1.mp3”; //the mp3 file uploaded into the same directory in the ftp as the swf file  
\_global.songs[2] = “song2.mp3”;  
\_global.songs[3] = “song3.mp3”;

\_global.playSong = function(){  
if(\_global.playing != “yes”){  
\_global.stopSong();  
\_global.songObject = new Sound();  
trace(\_global.songs[\_global.currentSong]);  
\_global.songObject.loadSound(\_global.songs[\_global.currentSong],true);  
\_global.songObject.onSoundComplete = function(){  
\_global.nextSong();  
\_global.playSong();  
}  
\_global.playing = “yes”;  
}  
};

\_global.stopSong = function(){  
\_global.songObject.stop();  
\_global.playing = “no”;  
};

\_global.nextSong = function(){  
numSongs = \_global.songs.length;  
numSongs -= 1;  
if(\_global.currentSong \< numSongs){  
\_global.currentSong += 1;  
}else{  
\_global.currentSong = 1;  
}  
if(\_global.playing == “yes”){  
\_global.stopSong();  
\_global.playSong();  
}  
trace(\_global.currentSong);  
};

\_global.prevSong = function(){  
numSongs = \_global.songs.length;  
numSongs -= 1;  
if(\_global.currentSong \> 1){  
\_global.currentSong -= 1;  
}else{  
\_global.currentSong = numSongs;  
}  
if(\_global.playing == “yes”){  
\_global.stopSong();  
\_global.playSong();  
}  
};

\_global.volumeUp = function(){  
vol = \_global.songObject.getVolume();  
if(vol \< 100){  
volume\_txt.text = vol;  
vol += 5;  
\_global.songObject.setVolume(vol);  
}

};  
\_global.volumeDown = function(){  
vol = \_global.songObject.getVolume();  
if(vol \> 0){  
volume\_txt.text = vol;  
vol -= 5;  
\_global.songObject.setVolume(vol);  
}  
};  
\_global.playSong();

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 12, 2004, 7:23pm UTC](https://forum.kirupa.com/t/can-i-loop-streamed-audio/42763/2 "2004-02-12T19:23:47Z")

</div>

crosseh
