Javascript MP3 Player

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Apr 2005
Posts: 1,403
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Javascript MP3 Player

 
1
  #1
Jul 10th, 2007
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
    1. var id2 = document.getElementById(typ);
  3. Below else if(typ == "item") add the following
    1. else if(typ == "load"){currentLoad = pr1;}
  4. After that line go below the if(typ == "time") add this line
    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
  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
  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.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 8
Reputation: Voynex is an unknown quantity at this point 
Solved Threads: 2
Voynex Voynex is offline Offline
Newbie Poster

Re: Javascript MP3 Player

 
0
  #2
Jul 24th, 2007
it is possible to do almost the same things using embedded windows media player 9 and above
voynex.com - high quality software and web development.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,620
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Javascript MP3 Player

 
0
  #3
Jul 24th, 2007
...which would work only for Windows.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC