# How can I loop streamed audio

**URL:** https://forum.kirupa.com/t/how-can-i-loop-streamed-audio/31442
**Category:** Uncategorized
**Created:** [September 22, 2003, 10:55pm UTC](https://forum.kirupa.com/t/how-can-i-loop-streamed-audio/31442 "2003-09-22T22:55:34Z")
**Posts on this page:** 4
**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: [September 22, 2003, 10:55pm UTC](https://forum.kirupa.com/t/how-can-i-loop-streamed-audio/31442/1 "2003-09-22T22:55:34Z")

</div>

Hey guys,

I want to make an entire song play as background music on my site. The mp3 is about 4 mb. I figure the only way to do this would be to stream the music off of the server. How can I do this and make it loop forever?

Thank-you very much,

artane

---

<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, 6:47pm UTC](https://forum.kirupa.com/t/how-can-i-loop-streamed-audio/31442/2 "2004-02-12T18:47:33Z")

</div>

hey kode,

I’m trying to apply your suggestion to the following script but, I can’t make it work. How can I loop the song that is currently playing until the user presses stop?

Thanks very much,

artane

```auto
_global.songs = new Array();
_global.playing = "no";
_global.currentSong = 1;
_global.songs[1] = "song1.mp3";
_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, 6:54pm UTC](https://forum.kirupa.com/t/how-can-i-loop-streamed-audio/31442/3 "2004-02-12T18:54:06Z")

</div>

Please do not crosspost artane.

---

<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, 6:59pm UTC](https://forum.kirupa.com/t/how-can-i-loop-streamed-audio/31442/4 "2004-02-12T18:59:01Z")

</div>

my apologies. It won’t happen again.

artane
