# Progress bar for streaming audio

**URL:** <https://forum.kirupa.com/t/progress-bar-for-streaming-audio/259733>\
**Category:** Uncategorized\
**Created:** [May 8, 2008, 8:30am UTC](https://forum.kirupa.com/t/progress-bar-for-streaming-audio/259733 "2008-05-08T08:30:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [May 8, 2008, 8:30am UTC](https://forum.kirupa.com/t/progress-bar-for-streaming-audio/259733/1 "2008-05-08T08:30:57Z")

</div>

Hello again…

I need some help with creating a progress bar for a mp3 player that loads mp3s with loadSound()

The problem is that the progress bar is not working correctly while the music is streaming (not completely downloaded to cache).

I can understand why it is so… (sound.duration is changing untill download is complete)

I have a simple progress bar… no masking etc:- … just using the good old “\_xscale”  
now how to correct the problem… please advice…

☹ please

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [May 8, 2008, 8:55pm UTC](https://forum.kirupa.com/t/progress-bar-for-streaming-audio/259733/2 "2008-05-08T20:55:14Z")

</div>

But this will show the loaded percentage i want the progress bar to show the current position percentage, because later this will be used as a seek bar as well

[quote=vamsig;2323505]Hello Friend,

I think it will help full for you… Please the following code… If in case you get any problem let me know…

var mysound:Sound = new Sound();  
mysound.loadSound(“audio name”);  
var lod:Number = mysound.getBytesLoaded();  
var total:Number = mysound.getBytesTotal();  
per = (lod/total)\*100;  
progressbar.\_xscale = per;[/quote]

---

<div class="post-metadata">

**Author:** ![chiqui](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@chiqui](https://forum.kirupa.com/u/chiqui)\
**Post date:** [May 8, 2008, 9:34pm UTC](https://forum.kirupa.com/t/progress-bar-for-streaming-audio/259733/3 "2008-05-08T21:34:39Z")

</div>

You have to use the same logic but replace _mysound.getBytesTotal();_ by _mysound.duration;_ and _mysound.getBytesLoaded();_ by _mysound.position;_.  
Check Sound class on flash help.
