MP3 player from Yahoo! – bookmarklet

January 23rd, 2008. Tagged: bookmarklets, JavaScript, Music, yahoo

Update Jan 30, 2008: updated code based on comments and code from Carl
Update Dec 11, 2008: updated the code thanks to the comment from Nolan

Here's the scenario: you have a page that links to some .mp3 files. You add a line of code in your page and lo and behold, there's a nice media player embedded into the page. Your visitors no longer have to download the MP3s, they can just stream it right there. All the mp3s on the page become part of a playlist.

The line in question you need to add to your page is:

<script src = ""></script>

More about the player here -

For examples of sites using this player in the wild, try

A bookmarklet

Now, here's what you can do if you want to use the player, but the web site owner haven't incorporated it yet. Take the player with you. Run my bookmarklet that will simply insert the required javascript into the page.

So here goes in two easy steps:

  1. Grab the bookmarklet:

    Right-click, add to favorites

  2. Go to any page that links to MP3s and click your new shiny bookmarklet



The readable source code of the bookmarklet:

  var start = function(){YAHOO.mediaplayer.loadPlayerScript()};
  var script = document.createElement('script');
  script.src = '';
    script.addEventListener("load", start, false);
  } else{
    script.onreadystatechange = function(){
        script = null;

Tell your friends about this post on Facebook and Twitter

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov