Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

XSPF web mp3 music player

There is one simple mp3 music player that supports xspf playlists, which can be found here: http://musicplayer.sourceforge.net/. We will modify it, so our songs stay secure and can't be downloaded and also change the text color of player and implement it in website.

To keep songs save there are 2 things to be aware of:

  1. built in download function in context menu
  2. xspf player list as parameter, so everyone can see where songs actually are

To bypass those 2 things we will modify ActionScript code. First define constants:

//constants
DEFAULT_PLAYLIST_URL = "mymp3.xspf";
DEFAULT_WELCOME_MSG = "Welcome to my site";
LOADING_PLAYLIST_MSG = "Loading Playlist...";
DEFAULT_LOADED_PLAYLIST_MSG = "- click to start";
DEFAULT_INFOBUTTON_TXT = "Track Info";

Add xspf playlist to DEFAULT_PLAYLIST_URL , so you won't have to pass it as parameter and cans secure your xspf files using mod_rewrite for example.

Edit welcome message and other text to your needs.

Next thing is to comment lines that will allow download your song like this:

//customized menu
var my_cm:ContextMenu = new ContextMenu();
my_cm.customItems.push(new ContextMenuItem("Stop", stopTrack));
my_cm.customItems.push(new ContextMenuItem("Play!", playTrack));
my_cm.customItems.push(new ContextMenuItem("Next", nextTrack));
my_cm.customItems.push(new ContextMenuItem("Previous", prevTrack));
//my_cm.customItems.push(new ContextMenuItem("Download this song", 
    function(){getURL(playlist_array[track_index].location)},true));
//my_cm.customItems.push(new ContextMenuItem("Add song to Webjay playlist", 
    function(){getURL("http://webjay.org/poster?media="+
    escape(playlist_array[track_index].location))}));
//my_cm.customItems.push(new ContextMenuItem("About Hideout", 
    function(){getURL("http://www.hideout.com.br")},true));
//my_cm.customItems.push(new ContextMenuItem("Crossfade", function(){}));
//my_cm.customItems.push(new ContextMenuItem("Mando Diao - Paralyzed", function(){}));
my_cm.hideBuiltInItems();
this.menu = my_cm;

And of course changing player style - it is easy to change the color of elements in .fla file, all you need is any flash program that can modify .fla files, double click on element and then paint it any color you want. But to change text color you need to add some code in the end of actionscript file:

var colorful = new Color("track_display_mc.display_txt");
colorful.setRGB(0xffffff);

0xffffff is a hex code for your color

Now to embed player to your website you can use swfobject or just put this simple code:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
codebase="http://fpdownload.macromedia.com/pub/
shockwave/cabs/flash/swflash.cab#version=7,0,0,0" 
width="228" height="15" id="xspf_player" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="/xspf_player_slim.swf?xn_auth=no" />
<param name="quality" value="high" />
<embed src="/xspf_player_slim.swf?xn_auth=no" quality="high" 
width="228" height="15" name="xspf_player" align="middle" 
allowScriptAccess="sameDomain" type="application/x-shockwave-flash" 
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus