Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with a DVD Player Script

Patti Frye
Registered User
Join date: 25 Aug 2006
Posts: 60
05-19-2007 23:36
Hi,
I'm new to scripting and still need to learn.

I've got a DVD player script I need some help with.
The script works fine as is, however in the dialog box I would like to make a change.
I would like the menu to list only the name of the video and not show the URL.
As it works now...it doesn't show any URL that starts with "http://" but it will show the URL if it starts with something like "rtsp://".
Anyway of correcting this to hide any and all URL's?

=================================


CODE
//              Notecard in the following format.
//
// Name of video
// http://www.url.com/urlofvideo.mov
// Second Video name
// http://www.url.com/urlofvideo2.mov
//*******************************************************************************

integer intChannel = -25;
string strMessage = "Movies \n\n";
string strDvdName = "Movies";

list lstVideoName = [];
list lstVideoUrl = [] ;
list lstButtons = ["<< +10", "First", ">> +10", "Pause", "Stop", "Resume", "<<", "Play", ">>"];

integer x = 0;
string gName;
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries

default
{
state_entry()
{
llSetText(strDvdName, <1,1,1>, 1.0);
llSetObjectName(strDvdName);
gName = llGetInventoryName(INVENTORY_NOTECARD, 0);
llListen(intChannel, "", "", "");
llSay(0, "Loading videos...please wait. This process may take a few moments...");
gQueryID = llGetNotecardLine(gName, gLine); //request first line
gLine++; // increase line count

}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), strMessage + (string)(x + 1) + ".) " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

listen(integer channel, string name, key id, string message)
{

integer intVideoAmount;
integer intLastVideo;

intVideoAmount = llGetListLength(lstVideoName);
intLastVideo = intVideoAmount - 1;

if (message == "Play")
{
llSay(0, "Now playing " + llList2String(lstVideoName, x));
llParcelMediaCommandList( [
PARCEL_MEDIA_COMMAND_URL, llList2String(lstVideoUrl, x),
PARCEL_MEDIA_COMMAND_PLAY] );
}

else if ((message == "<<") && (x != 0))
{
x = x - 1;
llDialog(id, strMessage + (string)(x + 1) + ".) " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

else if ((message == ">>") && (x != intLastVideo))
{
x = x + 1;
llDialog(id, strMessage + (string)(x + 1) + ".) " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

else if ((message == "<<") && (x == 0))
{
x = intLastVideo;
llDialog(id, strMessage + (string)(x + 1) + ". " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

else if ((message == ">>") && (x == intLastVideo))
{
x = 0;
llDialog(id, strMessage + (string)(x + 1) + ". " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

else if (message == "Pause")
{
llSay(0, "Video paused...");
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_PAUSE ] );
}

else if (message == "Stop")
{
llSay(0, "Stopping video playback.");
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_STOP, PARCEL_MEDIA_COMMAND_UNLOAD ] );
}

else if (message == "Resume")
{
llSay(0, "Resuming video.");
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_PLAY ] );
}

else if (message == "<< +10")
{
x = x - 10;
llDialog(id, strMessage + (string)(x + 1) + ". " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

else if (message == ">> +10")
{
x = x + 10;
llDialog(id, strMessage + (string)(x + 1) + ". " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

else if (message == "First")
{
x = 0;
llDialog(id, strMessage + (string)(x + 1) + ". " + llList2String(lstVideoName, x), lstButtons, intChannel);
}

}

dataserver(key query_id, string data)
{
if (query_id == gQueryID)
{
if (data != EOF)
{
if (llGetSubString(data, 0, 4) != "http:")
{
lstVideoName = lstVideoName + [data];
gQueryID = llGetNotecardLine(gName, gLine); // request next line
gLine++; // increase line count
}
else
{
lstVideoUrl = lstVideoUrl + [data];
gQueryID = llGetNotecardLine(gName, gLine);
gLine++;
}
}
else
{
llSay(0, "Videos loaded!");
}
}
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
05-20-2007 06:49
Without seeing the notecard I can't be certain how this works, but your URLs are being identified in this section of code (which is reading the notecard):

CODE
if (llGetSubString(data, 0, 4) != "http:") // non urls here
{
lstVideoName = lstVideoName + [data];
gQueryID = llGetNotecardLine(gName, gLine); // request next line
gLine++; // increase line count
}
else // urls here
{
lstVideoUrl = lstVideoUrl + [data];
gQueryID = llGetNotecardLine(gName, gLine);
gLine++;
}
I think perhaps it should have:

if (llGetSubString(data, 0, 4) != "http:" && != "rtsp:";)

...plus any other protcols you think it should treat as a URL.
Patti Frye
Registered User
Join date: 25 Aug 2006
Posts: 60
05-20-2007 15:23
Thanks for you help Pale but I get a Syntax Error here in this line,

CODE
if (llGetSubString(data, 0, 4) != "http:" && != "rtsp:")  // non urls here



By the way,
NOTECARD would be in this format:

Movie Name
rtsp://****/****/***.mp4
Movie Name
http://i****/****/***.mp4
Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
05-20-2007 19:33
CODE
if (llGetSubString(data, 0, 4) != "http:" && llGetSubString(data, 0, 4)  != "rtsp:")  // non urls here 
_____________________
IgenG Amsterdam
Registered User
Join date: 7 Dec 2006
Posts: 6
Maybe i broke it???
05-21-2007 01:23
I tried the Script and i think i broke it cause i always get the following Message:

[1:20] Movies: Loading videos...please wait. This process may take a few moments...
[1:21] Movies: Script run-time error
[1:21] Movies: Stack-Heap Collision


What have i done?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-21-2007 01:41
From: IgenG Amsterdam
I tried the Script and i think i broke it cause i always get the following Message:

[1:20] Movies: Loading videos...please wait. This process may take a few moments...
[1:21] Movies: Script run-time error
[1:21] Movies: Stack-Heap Collision


What have i done?


Probability is that you have too many items in your notecard.
You can try using the memory reclaim hack to improve things but if you have too many items you will still get this.

CODE
lstVideoName = (lstVideoName = []) + lstVideoName + [data];

and
CODE
lstVideoUrl = (lstVideoUrl = []) + lstVideoUrl + [data];
_____________________
I'm back......
IgenG Amsterdam
Registered User
Join date: 7 Dec 2006
Posts: 6
05-21-2007 03:27
I put 75 previews inside, is that too much?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-21-2007 04:40
From: IgenG Amsterdam
I put 75 previews inside, is that too much?


If its causing a crash then yes.........
_____________________
I'm back......
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-21-2007 06:28
Try it with 30, then add 5 to it until you crash. At that point take the last 5 out.

75 is probably way too many for the memory restrictions on LSL.
Chiman Fassbinder
LV CEO/Terminal Radio CEO
Join date: 3 Sep 2005
Posts: 66
05-21-2007 09:07
the script will handle roughly 50 videos give or take, or at least thats what it would handle when i wrote it. because it reads so that you have your description on the dialog menu and then cross references it to that url it can only handle so much data in the notecard. off the top of my head i forget what the limits are with notecard readers
IgenG Amsterdam
Registered User
Join date: 7 Dec 2006
Posts: 6
05-21-2007 19:02
well, that sounds not so logic to me cause my tv contains a notecard with the 75 previews AND 170 movie urls. and i never had any issues with it thats why i wonder about the dvd player.
Patti Frye
Registered User
Join date: 25 Aug 2006
Posts: 60
05-21-2007 20:52
From: Chiman Fassbinder
the script will handle roughly 50 videos give or take, or at least thats what it would handle when i wrote it.




Thanks for the input Chiman. You wrote a great script. Just trying to get it to work a little different for my own use.
Also I want to thank CystalShard Foo for her FreeView TV script. And setting it up as an Open Source script.
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
05-22-2007 03:52
From: IgenG Amsterdam
well, that sounds not so logic to me cause my tv contains a notecard with the 75 previews AND 170 movie urls. and i never had any issues with it thats why i wonder about the dvd player.

Your TV is probably using realtime scanning of the notecard as needed or extra scripts for memory.
_____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
IgenG Amsterdam
Registered User
Join date: 7 Dec 2006
Posts: 6
05-22-2007 04:03
yes, maybe thats the reason, anyway, its a great script uve done Christian !!!
IgenG Amsterdam
Registered User
Join date: 7 Dec 2006
Posts: 6
05-22-2007 04:03
ups, i mean Chiman:))
Alexander Yeats
Registered User
Join date: 8 Sep 2005
Posts: 188
10-18-2007 15:12
From: Patti Frye
Thanks for the input Chiman. You wrote a great script.


Yeah, those are some mad coding skillz! ;p