RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 9940 | Replies: 2
Reply
Join Date: Apr 2005
Location: New York state
Posts: 501
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 6
Solved Threads: 78
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Javascript MP3 Player

  #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 z+*
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Posts: 8
Reputation: Voynex is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
Voynex Voynex is offline Offline
Newbie Poster

Re: Javascript MP3 Player

  #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  
Join Date: Jun 2006
Location: India
Posts: 7,054
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 372
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Javascript MP3 Player

  #3  
Jul 24th, 2007
...which would work only for Windows.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:14 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC