zzzz

Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Music Simple_MP3_music_player  

Simple_MP3_music_player

Add music URLs to a list, and call 'play(llDumpList2String(playlist,","));'

This function then builds the necessary data for autostarting the music , continually streaming the mp3's back-to-back, and loops them when done.

Your limit is 1024K bytes for the embedded URL's, which is a lot of URL's, even when the escape function triples some of the characters

Category: Music
By : Ferd Frederix
Created: 2010-06-16 Edited: 2010-06-16
Worlds: Second Life + OpenSim

the Zip file

Download all files for Simple_MP3_music_player
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Simple_MP3_music_player_1.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Author: Ferd Frederix
2 // simple mp3 player for SL
3 // See http://wpaudioplayer.com/standalone/ for details
4
5
6
7 // Add music URLs to a list, and call 'play(llDumpList2String(playlist,","));'
8 //
9 //This function then builds the necessary data for autostarting the music , continually streaming the mp3's back-to-back, and loops them when done.
10 //
11 //Your limit is 1024K bytes for the embedded URL's, which is a lot of URL's, even when the escape function triples some of the characters
12 //
13 // Author: Ferd Frederix
14 // simple mp3 player for SL
15 play(string url)
16 {
17
18 if (llStringLength(url) > 1024)
19 {
20 llOwnerSay("Too many files!");
21 return;
22 }
23
24 string html = "<html><head><script src=\"http://secondlife.mitsi.com/cgi/audio-player/audio-player.js\"></script><script>AudioPlayer.setup(\"http://secondlife.mitsi.com/cgi/audio-player/player.swf\", {width:290});</script></head><body><p id=\"a\"></p><script>AudioPlayer.embed(\"a\",{soundFile: \""
25 + url + "\",autostart:\"yes\",loop:\"yes\"});</script></body></html>";
26
27
28
29 html = "data:text/html," + llEscapeURL(html); // you may need to escape funny chars
30 // html = "data:text/html," + html; // or not, this depends upon your URL's
31 if (llStringLength(html) > 32768)
32 llOwnerSay("Web page too big!");
33 else
34 llSetPrimMediaParams(0, // Side to display the media on.
35 [PRIM_MEDIA_AUTO_PLAY,TRUE, // Show this page immediately
36 PRIM_MEDIA_CURRENT_URL,html, // The url currently showing
37 PRIM_MEDIA_HOME_URL,html, // The url if they hit 'home'
38 PRIM_MEDIA_HEIGHT_PIXELS,512, // Height/width of media texture will be
39 PRIM_MEDIA_WIDTH_PIXELS,256 // rounded up to nearest power of 2.
40 ]);
41
42 }
43
44 default
45 {
47 {
48 list playlist = [
49 "http://www.mrtv4.com.mm/sites/www.mrtv4.com.mm/files/toptensongs/11825/2.%20Pink%20-%20Just%20Give%20Me%20A%20Reason.mp3",
50 "http://ed101.bu.edu/StudentDoc/Archives/spring04/jgc/sounds/songs/classical music - mozart - marriage of figaro.mp3"
51 ];
52 // You can use or http://bit.ly or http://tinyurl.com URL's to save room , as the total length must be < 1024
53 play(llDumpList2String(playlist,","));
54 }
55 }