Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSetParcelMusicURL questions

Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
01-22-2007 08:54
I wrote the following script to handle a list of individual mp3s. Right now, I've only put in one mp3 URL, which I want it to repeat. It will play once, then the timer hits, SAYS the information, but then the music does not play again. Any ideas why?

CODE

//Music player
//by Baron Hauptmann
//January, 2007

//globals
//keep track of song and length in strided list
list SongList = ["http://urlgoeshere.com", 215.0]; //has real URL, commented out for posting
string CurrentSongURL;
float CurrentSongLength;
integer CurrentStride = 0;
integer IsOn = FALSE;
integer StrideCount = 0;

// Returns number of Strides in a List
integer fncStrideCount(list lstSource, integer intStride)
{
return llGetListLength(lstSource) / intStride;
}

// Returns a Stride from a List
list fncGetStride(list lstSource, integer intIndex, integer intStride)
{
integer intNumStrides = fncStrideCount(lstSource, intStride);

if (intNumStrides != 0 && intIndex < intNumStrides)
{
integer intOffset = intIndex * intStride;
return llList2List(lstSource, intOffset, intOffset + (intStride - 1));
}
return [];
}

default
{
state_entry()
{
CurrentSongURL = llList2String(SongList, 0);
CurrentSongLength = llList2Float(SongList, 1);
llSetParcelMusicURL(CurrentSongURL);
StrideCount = fncStrideCount(SongList, 2);
}

touch_start(integer num_detected)
{
IsOn = !IsOn;
if (IsOn) //music has been turned on
{
llSetParcelMusicURL(CurrentSongURL);
llSetTimerEvent(CurrentSongLength);
llSetText(CurrentSongURL, <1.0, 1.0, 1.0>, 1.0);
} else
{
llSetParcelMusicURL("");
llSetTimerEvent(0.0);
llSetText("music is off", <1.0, 1.0, 1.0>, 1.0);
}
}

timer()
{
llSay(0, "StrideCount = " + (string)StrideCount);
CurrentStride++;
if (CurrentStride = StrideCount)
CurrentStride = 0;
list nextStride = fncGetStride(SongList, CurrentStride, 2);
CurrentSongURL = llList2String(nextStride, 0);
CurrentSongLength = llList2Float(nextStride, 1);
llSay(0, CurrentSongURL);
llSetParcelMusicURL(CurrentSongURL);
llSetTimerEvent(CurrentSongLength);
}
}


Thanks,
Baron H.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-22-2007 10:17
From: Baron Hauptmann
It will play once, then the timer hits, SAYS the information, but then the music does not play again. Any ideas why?

My first guess would be that since you're not changing the URL, just setting it to what it already is, it doesn't try to re-start the stream. Try blanking the URL first, perhaps followed by a short pause ( llSleep( #.# ) ), then change the URL back.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
01-22-2007 10:37
Funny how the obvious things can escape you. I had thought of that at one point, then forgot to try it. That seems to have worked. I just added to the timer a call to llSetParcelMusicURL("", time).