944,097 Members | Top Members by Rank

Ad:
Jul 10th, 2007
1

Javascript MP3 Player

Expand Post »
Most likely you've seen a flash MP3 player or two while searching the web but I have a favorite. This is the JW MP3 Player, mainly because it has external JavaScript functions that can be used to access data about the player dynamically. I've written a few things for it that don't come "standard." While searching around I found a CSS progress bar and found it pretty pointless since it's static, then I put 2 and 2 together. This is a little script that can be used with the external functions of the MP3 player to show the loading buffer.

The JavaScript for the external functions are found at http://www.jeroenwijering.com/extras/javascript.html
After adding the the variables to allow external javascript functions in the player (explained in the readme).
  1. Add a currentLoad variable to the script.
  2. Inside of the getUpdate function add
    javascript Syntax (Toggle Plain Text)
    1. var id2 = document.getElementById(typ);
  3. Below else if(typ == "item") add the following
    javascript Syntax (Toggle Plain Text)
    1. else if(typ == "load"){currentLoad = pr1;}
  4. After that line go below the if(typ == "time") add this line
    javascript Syntax (Toggle Plain Text)
    1. else if(typ == "load"){id2.style.width = (currentLoad-1)+"%" ;}
Done with the JavaScript, now onto the CSS for the image-less progress bar.
In your stylesheet add the following
css Syntax (Toggle Plain Text)
  1. #prog-border {
  2. height: 13px;
  3. width: 205px;
  4. background: #e6d3a9;
  5. margin: 0;
  6. }
  7. #load {
  8. height: 10px;
  9. margin: 1px;
  10. padding-right: 1px;
  11. background: #006600;
  12. width: 0%;
  13. }

The colors can be changed any way you like which is the reason why I chose to go with the JavaScript external functions rather than the flash player.

Wherever you want your progress bar to display put
html Syntax (Toggle Plain Text)
  1. <div id="prog-border">
  2. <div id="load"></div>
  3. </div>

Note: The script could be easily modified to allow the progress bar to be the play time though it would require some extra math to change the seconds to a % of the running time.

Here it is in action at the bottom of the page. The entire player is using the JavaScript functions, a table, some css and the silk iconset
Last edited by ShawnCplus; Jul 10th, 2007 at 3:58 pm.
Similar Threads
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jul 24th, 2007
0

Re: Javascript MP3 Player

it is possible to do almost the same things using embedded windows media player 9 and above
Reputation Points: 6
Solved Threads: 3
Newbie Poster
Voynex is offline Offline
15 posts
since Jul 2007
Jul 24th, 2007
0

Re: Javascript MP3 Player

...which would work only for Windows.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: urgent- i have dead line
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Open.window popup





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC