Posted January 17, 2011 by Nick Vogt in Programming
I mentioned I was working on an MP3 player in a previous post. I considered writing a tutorial but it would be really long. Instead, I'm releasing the MP3 player, free to use and modify, and am offering the full Actionscript 3 source code (plus Photoshop file) for download.
Here is the MP3 player. Let me know if you find any bugs. The initial values for the text in the title is changeable in the XML file. The scroll bar resizes based on the number of mp3s (or disappears if there aren't that many).
Continue reading...
Here is the MP3 player. Let me know if you find any bugs. The initial values for the text in the title is changeable in the XML file. The scroll bar resizes based on the number of mp3s (or disappears if there aren't that many).
Continue reading...
Posted February 19, 2010 by Nick Vogt in Programming
While creating a dynamic music player for the web in flash (AC3) I ran across a bit of an issue. When attempting to get the length of a song using the .length function, flash only returns the length of what it has loaded so far. Until the sound is fully loaded, flash is unable to tell you the length in seconds of that sound file. I found a solution that works well and doesn't rely on the length being manually inputted or pulled from the ID3 tags.
Utilizing Actionscript 3's .bytesTotal and .bytesLoaded functions, we can obtain the total file size of the sound file in bytes and how many bytes have been loaded thus far. Then using the .length function we can obtain the length in seconds that have been loaded. After that it's just a quick math equation and we get the total length of the song in milliseconds. soundLength = mySound.length / mySound.bytesLoaded * mySound.bytesTotal. Keep in mind that the total seconds won't be completely accurate for the first 1%~ of the sound. Just have it display a loading message first. For fast connections they likely won't even notice it.
Continue reading...
Utilizing Actionscript 3's .bytesTotal and .bytesLoaded functions, we can obtain the total file size of the sound file in bytes and how many bytes have been loaded thus far. Then using the .length function we can obtain the length in seconds that have been loaded. After that it's just a quick math equation and we get the total length of the song in milliseconds. soundLength = mySound.length / mySound.bytesLoaded * mySound.bytesTotal. Keep in mind that the total seconds won't be completely accurate for the first 1%~ of the sound. Just have it display a loading message first. For fast connections they likely won't even notice it.
Continue reading...

