Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Play a media url, then play another url, consecutively

ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
12-28-2007 08:01
Well, the title basically says it..I'm trying to find out if it's possible to play a url, then change the url and play another, and how?
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
12-28-2007 09:19
I assume, you wanna play an MP3-Playlist?

So - simply make a script that connects to the first MP3. The script has to know how long the MP3 is (you can't read this out from the ID3-Tag without an external script).
Set up a timer that fires after the first MP3-file is finished. Set the parcel-url to the next MP3 and set up the timer according to the length of this MP3 and so on...

You might use a strided list that looks like this (pseudo code!):

CODE

list streams = ["http://www.myserver.com/first.mp3", 7.2, "http://www.myserver.com/second.mp3", 5.3, ... ];

//where the first value would be the URL of the stream and the second value would be the duration. Be aware that the time is set in decimal notation so a stream that has a duration of 7 minutes, 30 seconds would be 7.5!

integer list_length = llGetListLength(streams);
integer act_title = 0;

// We declare a little function for the stream to play

play_stream(string url, float time)
{
llSetParcelMusicURL(url); // Set the Parcel-Music-Url

llSetTimerEvent(time); // Set the Timer-Event to the end of the tune
}

default
{

// Play the first title on script entry

state_entry()
{
string url = llList2String(streams, act_title);
float time = llList2Float(streams, act_title + 1);

play_stream(url, time);

}

// Now for the timer

timer()
{

llSetTimerEvent(0);
act_title += 2; // raise the title-counter;

if(act_title >= list_length) // We reached the end of the list -> start over
act_title = 0;

// Set the new stream

string url = llList2String(streams, act_title);
float time = llList2Float(streams, act_title + 1);

play_stream(url, time);

}
}


This is untested and may have bugs :)

Be aware that the object that runs the script has to have permissions to set the Parcel-Music-URL. So if you are on group-owned land, you have to deed the object to the group, otherwise it won't work.
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
12-28-2007 09:29
Maybe he only wants to play a radio online, and not play an mp3 list, the function that he needs is the one that you have in that script:

"llSetParcelMusicURL(url);"
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
12-28-2007 09:31
Well - assumptions :)

He can strip down the script whenever he likes. But still - the function of a timed change would be handy, I guess...
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
Actually, it's media
12-28-2007 12:14
lol..that's a very good idea, that timer, I hadn't thot of that. Thanks!

Actually, I want to play a video, then at the end of it, move on to the next video. Same concept, though. But the wiki implies I should be able to do this simply by using

llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_URL,"myvideourl",PARCEL_MEDIA_COMMAND_PLAY]);
which supposedly plays to the last frame - then the implication is that it SHOULD move on, having reached the last frame, to the next command in the script. However, LOL, it doesn't do this, and it's driving me crazy. It zips thru, setting the urls, until it hits the last one, and plays that one.

Any ideas? The timer might actually work, but I really thought there'd be a way to make the script run commands in succession as written. Maybe I'm just expecting more of LSL than it's capable of, I'm not sure.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
12-28-2007 12:57
Well, the entry in the wiki does say that the video stops, when it reached its end. To me that's kinda «duh», because - what else should it do? Play backwards? Make a cup of coffee? :)

Problem is, when you start the video, the script which turned the video on keeps running.

Since QuickTime-stuff runs independently from SL (MP3-streams and video-URLs are just passed to the client which then runs the stuff), you don't have a chance to know when a video or a stream starts or ends.

So the only way to make the next movie start is use the timer()-event as described in my example...

On the LSL-Wiki, you'll find an example that describes what you want to do:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llParcelMediaCommandList
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
12-28-2007 15:02
From: Haruki Watanabe
Well, the entry in the wiki does say that the video stops, when it reached its end. To me that's kinda «duh», because - what else should it do? Play backwards? Make a cup of coffee? :)

Problem is, when you start the video, the script which turned the video on keeps running.

Since QuickTime-stuff runs independently from SL (MP3-streams and video-URLs are just passed to the client which then runs the stuff), you don't have a chance to know when a video or a stream starts or ends.

So the only way to make the next movie start is use the timer()-event as described in my example...

On the LSL-Wiki, you'll find an example that describes what you want to do:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llParcelMediaCommandList



that's awesome! I never found that page before! Thanks for the help!