# Preloader for LoadSound() object

**URL:** <https://forum.kirupa.com/t/preloader-for-loadsound-object/150485>\
**Category:** Uncategorized\
**Created:** [June 7, 2005, 8:53pm UTC](https://forum.kirupa.com/t/preloader-for-loadsound-object/150485 "2005-06-07T20:53:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![logikal2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/logikal2/32/1143_2.png) [@logikal2](https://forum.kirupa.com/u/logikal2)\
**Post date:** [June 7, 2005, 8:53pm UTC](https://forum.kirupa.com/t/preloader-for-loadsound-object/150485/1 "2005-06-07T20:53:20Z")

</div>

Hey guys, I was just wondering if it’s possible to create a working loadbar giving the status on a streaming mp3 file. All i want to do is, while the file is playing, for a little animation to show the percentage of the file that has actually been downloaded so far. F.Y.I. I checked out the code to Voets.’ streaming xml player and that didn’t help. Any ideas on how to get the percentage bar working?

For more information:

**redload** is a movie clip that should increase in width until reaching 100% (150 pixels wide), determined by bytes\_loaded/bytes\_total.

All **music.php** does is sends the full address of an mp3 file using the variable **playsong**.

Unfortunately, the percentageBar (loadbar) doesn’t work and is commented out.

// CODE ----------------------------------------\>

loadMySong = function () {  
[//this.mplayer.redload](https://this.mplayer.redload).\_width = 1.0;  
htmlData = new LoadVars();  
htmlData.load(“music.php?dummy=” + Math.random());  
htmlData.onLoad = function (true) {  
if (true) {  
playsong = this.play;  
songname = this.name;  
}  
}  
};

/_this.mplayer.percentageBar = function (true)  
{  
loaded = Math.round(theStream.getBytesLoaded());  
total = Math.round(theStream.getBytesTotal());  
getPercent = loaded/total;  
this.mplayer.redload.\_width = getPercent \* 150;  
};_/

var theStream = new Sound();  
mplayer.now\_playing = “go ahead, make my day”;  
loadMySong();

mplayer.pause.onPress = function ()  
{  
theStream.stop();  
mplayer.now\_playing = “—”;  
};

mplayer.play.onPress = function ()  
{  
loadMySong();  
theStream.stop();  
mplayer.now\_playing = songname;  
theStream.loadSound(“[http://localhost:8000](http://localhost:8000)”+playsong, true);  
//percentageBar();  
};
