1) Accepts a notecard with URLs to movie files on each line
2) Plays the first movie right after the card is given
3) Has a dialog with basic video controls
The code I posted below seems to execute differently each time I run it but aside from that I have a few questions and issues...
1) The first URL in a sample notecard (below) doesn't play. I have llSay calls at the top of cycle_playlist and no number and a blank string are printed for the first URL in the playlist. However when the timer event goes off the length of the list is 3. The other items in the playlist cycle correctly....samepl notecard used...
http://www.perp.com.nyud.net:8090/whale/av/whale-hi.mov
http://www.esm.psu.edu/Faculty/Gray/graphics/movies/Think-Different.mov
http://www.perp.com.nyud.net:8090/whale/av/whale-hi.mov
2) I need help using timers to cycle through the playlist (a list with URLs read from the notecard)...also...must each movie's length be defined beforehand? Is there meta-data I can get from the movie prior to playing it?
Anyway, I appreciate any help or tips and I hope this makes some sense!
Thanks,
newbie Epilort
CODE
float START_TIME = 1.0;
float RUN_LENGTH = 20.0;
key VID_TEXTURE;
integer CURRENT_VID_INDEX = -1;
integer CHANNEL = 1;
list MENU_OPTS = ["Next movie", "Stop Playing"];
list nc_urls = [];
string nc_name;
key nc_queryid;
integer nc_line;
integer nc_total_urls;
integer DS_READY = FALSE;
cycle_playlist()
{
++CURRENT_VID_INDEX;
llSay(0, (string) CURRENT_VID_INDEX);
llSay(0, "Now playing: " + llList2String(nc_urls, CURRENT_VID_INDEX));
llSetTexture("Blue Plasma", ALL_SIDES);
llParcelMediaCommandList ( [
PARCEL_MEDIA_COMMAND_URL, llList2String(nc_urls, CURRENT_VID_INDEX),
PARCEL_MEDIA_COMMAND_AGENT, llDetectedKey(0),
PARCEL_MEDIA_COMMAND_TIME, START_TIME,
PARCEL_MEDIA_COMMAND_TEXTURE, VID_TEXTURE,
PARCEL_MEDIA_COMMAND_PLAY ] );
llSetTimerEvent(RUN_LENGTH);
}
default
{
on_rez(integer number)
{
llResetScript();
}
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");
VID_TEXTURE = llGetInventoryKey("Blue Plasma");
}
touch_start(integer number)
{
llDialog(llDetectedKey(0), "Select an option...", MENU_OPTS, CHANNEL);
}
listen(integer channel, string name, key id, string message)
{
if (llListFindList(MENU_OPTS, [message]) != -1)
{
if (message == "Next Movie")
cycle_playlist();
if (message == "Stop Playing")
{
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_UNLOAD,
PARCEL_MEDIA_COMMAND_URL, "" ] );
llSetTexture("ll_buildside_billboard", ALL_SIDES);
llSetTimerEvent(0.0);
}
}
else
llSay(0, "Invalid option.");
}
changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
CURRENT_VID_INDEX = -1;
nc_name = llGetInventoryName(INVENTORY_NOTECARD, 0);
nc_urls = [];
nc_line = 0;
nc_queryid = llGetNotecardLine(nc_name, nc_line);
if (DS_READY)
cycle_playlist();
}
}
dataserver(key query_id, string data)
{
if (query_id == nc_queryid)
{
if (data != EOF)
{
nc_urls += data;
++nc_line;
nc_queryid = llGetNotecardLine(nc_name, nc_line);
}
else
DS_READY = TRUE;
}
}
timer()
{
llSay(0, (string) llGetListLength(nc_urls));
if ((CURRENT_VID_INDEX + 1) == llGetListLength(nc_urls))
{
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_UNLOAD,
PARCEL_MEDIA_COMMAND_URL, "" ] );
llSetTexture("ll_buildside_billboard", ALL_SIDES);
llSetTimerEvent(0.0);
}
else
cycle_playlist();
}
}