Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Music Playing From UUID Problems

Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 01:43
Hello all im currenty working on a dialog driven music player, now i have looked through the forums for reusable scripts and the Psyke Phaeton modified inventory music player and its just not what im trying to do and i did try to convert it to what i was trying to do but made a total hash of that so i started my own attempt and failed lol plus there was alot of comments and everything from people adding to it and commenting it was hard to read at times even in sl copy and pasted.

What the script is trying to do and i will post a snippet of it below is call the UUID after preloading the sound files then play them one by one in order according to the set trigger i have set up in llDialog for the player itself obviously im not going to post the UUID's but heres what i got so far.

CODE

//Created By Jodie Suisei 25/08/08
//Free To Use If You Get It Working But I Provide Limited Support For llDialog And Link Messaging As This Script Is Setup To Use It As I Am Just A Learner Scripter :)
// If You Do Use The Script Please Dont Remove These Upper Comments :)

list sound_UUID = ["UUID1","UUID2","UUID3"]; // All UUID's For sounds to be preloaded
list sound_UUID2 = ["UUID1","UUID2","UUID3"]; // More UUID's To Be Preloaded

float timer_interval = 8.9; // Basic Timer Control But Havent Worked Out The Way To Get It Working Properly

default
{
link_message(integer sender_num, integer num, string str, key id)
{

if(str == "pup")
{
llOwnerSay("Preloading Music UUID's");
llSetTimerEvent(timer_Interval);// Timer Trigger On PuP
llPreloadSound(sound_UUID); // Self Explanatory Really, Will Load All Sounds When Recieves The Link message To Before It Plays Anything
llPreloadSound(sound_UUID2);
llOwnerSay("Done Preloading Music UUID's");
}
if(str == "pdown")
{
llSetTimerEvent(0.0);// Turns Timer Off When Pdown
llStopSound(); // Will Stop All Sounds Running In The Script.
llOwnerSay("Turning Off");
}
if(str == "song1")
{
llSetTimerEvent(0.0);// Tells the Timer To stop When This Message Is Recieved
llStopSound();
llSetTimerEvent(timer_interval);// Tells it to restart its timer based on the interval
llPlaySound(sound_UUID,1.0);
}
if(str == "song2")
{
llSetTimerEvent(0.0);
llStopSound();
llSetTimerEvent(timer_interval);
llPlaySound(sound_UUID2,1.0);
}
}
}


Please note i selectivly removed some of the code and change some of the naming on some of the link commands i done this because this script was mainly developed for a product that i will be selling but if people can help get it working to play sounds from UUID in the right order when told to then people may use it for there own creations or as just reference if they are stuck like me as i know this has racked my brain to bits with a tooth pick lol.

Now what i cant get working properly is the music to play in order of the UUID and on a timer of 8.9 the music im trying to get to work is exactly 9 seconds fluid cut as i done it myself the music player script out around already is nice to reference to but putting alot of sound files into a contents tab is very messy and you cant choose what you want to hear only let it play through.

And if it does play will play the first two UUID then just stops or it will attempt to play all at once and only the last to be read is heard without problems.

I can get it working however if i split up the preloading and sound playing with llSleep(timer_interval); & Use llPlaySound(sound_UUID1, 1.0); 2 3 4 for each single UUID but this is very messy also you loose all control of stopping the sounds untill they have finished playing away and if you choose another set of sounds to play it will queue up untill this one has finished then play but this is and isnt what im trying to do lol.

Mainly want the system to queue up like a real world music player would but without the problems of the music keeping on playing untill it had finished what it is doing in the script. or if you choose another track to stop the current playing sound then play the new.

But if can get it to play without having to queue up thats good also i just miss the knowledge of fixing the timer to play the UUID's in seqeuence from the list and the code :(

Any help on getting my frankenstein creation to work as im trying to get would be great.

My apologise for the long post more than coding but i thought would be best to put as much info about the problems with the script as possible.
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-26-2008 05:47
On first look I see 2 glaring mistakes:

you define float timer_interval = 8.9;
but you call llSetTimerEvent(timer_Interval);

remember that Variables are Case sensitive

and secondly the syntax for llPreloadSound is wrong, it takes a string argument, you are passing it a list in 4 separate places.
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 06:21
thank you for the pointers but the timer_interval was just a typo on my part from copy and pasting it over from the ingame editor.

additionally i found on the forums ones sound looping script and tried to adapt it to fit what i needed unfortunatly im bordering on deleting the scripts and not bothering as i just cant get it work no matter what i try to do

but anyway here is the code that im trying to get to work minus spelling errors and no UUID's

CODE

list song1= ["uuid","uuid2"];
list song2= ["uuid","uuid2"];

integer gSoundIx;
float timer_interval = 8.9;

default
{
state_entry()
{
llSetSoundQueueing(TRUE);
llSetTimerEvent(timer_interval);
}

link_message(integer sender_num, integer num, string str, key id)
{

if(str == "pup")
{
llOwnerSay("Powering Up... Please Wait..");
llPreloadSound(llList2String(song1, gSoundIx));
llPreloadSound(llList2String(song2, gSoundIx));
llOwnerSay("Finished Powering Up.... Ready..");
}
if(str == "song1")
{
llPlaySound(llList2String(song1, gSoundIx),1);
}
if(str == "song2")
{
llPlaySound(llList2String(song2, gSoundIx),1);
}
if(str == "pdown")
{
llOwnerSay("Powering Down....");
}
}
timer()
{
if ( ++gSoundIx < llGetListLength(song1) )
{
llPreloadSound(llList2String(song1, gSoundIx));
}
if ( ++gSoundIx < llGetListLength(song2) )
{
llPreloadSound(llList2String(song2, gSoundIx));
}
else
{

}
}
}


now this code that i tried to adapt with list2strings works fine on a loop timer in a prim dont remember who originally posted it but it worked so i tried to adapt it to work on my menu triggers and now im stuck again as it only plays the first UUID and on the loop timer it will play through all the UUID withs no problem
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-26-2008 06:51
You need some kind of loop, in this line:
llPreloadSound(llList2String(song1, gSoundIx));

you are refering to an index gSoundIx but have not assigned a value to it, in the timer you have if ( ++gSoundIx < llGetListLength(song1) ) so that will increment each time the timer trigers.

Try this:

CODE

list song1= ["uuid","uuid2"];
list song2= ["uuid","uuid2"];

integer gSoundIx;
float timer_interval = 8.9;

default
{
state_entry()
{
llSetSoundQueueing(TRUE);
llSetTimerEvent(timer_interval);
}

link_message(integer sender_num, integer num, string str, key id)
{

if(str == "pup")
{
llOwnerSay("Powering Up... Please Wait..");
for( ; gSoundIx < llGetListLength(song1); gSoundIx++)
{
llPreloadSound(llList2String(song1, gSoundIx));
}
for( ; gSoundIx < llGetListLength(song2); gSoundIx++)
{
llPreloadSound(llList2String(song2, gSoundIx));
}
llOwnerSay("Finished Powering Up.... Ready..");
}
if(str == "song1")
{
for( ; gSoundIx < llGetListLength(song1); gSoundIx++)
{
llPlaySound(llList2String(song1, gSoundIx),1);
}
}
if(str == "song2")
{
for( ; gSoundIx < llGetListLength(song2); gSoundIx++)
{
llPlaySound(llList2String(song2, gSoundIx),1);
}
}
if(str == "pdown")
{
llOwnerSay("Powering Down....");
}
}
timer()
{
if ( ++gSoundIx < llGetListLength(song1) )
{
llPreloadSound(llList2String(song1, gSoundIx));
}
if ( ++gSoundIx < llGetListLength(song2) )
{
llPreloadSound(llList2String(song2, gSoundIx));
}
else
{

}
}

}


And dont give up, LSL can be frustrating but once you crack it, it is one of the most rewarding aspects of SL>
We are all here to help so feel free to ask
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 08:44
i tried those changes you had made not one problem compiling them but when the play control for the link message is hit it does not play anything now :(
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-26-2008 08:56
From: Jodie Suisei
i tried those changes you had made not one problem compiling them but when the play control for the link message is hit it does not play anything now :(

my original post did not have the loop for the play portion, take a look at the update I did and make sure you did not copy it whilst I was editing it.
If this won't work then you will have to provide more of your script as I cant test it without sound files and have no idea how you are calling it.
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 09:09
im calling the files from UUID's in lists as for more of the script you got everything apart from the UUID's which im not about to publicly display or give out which cost me 200L$ + each to upload. the menu dialog controller there is no no faults with that i have checked it total ness of this working / not working lays totally within this script that im trying to get working.

EDIT

i do have a test simple "welcome"sound file uploaded im more than willing via PM or Inworld as im logged in able to provide that as a test ground to make sure everything is working


Could not find sound ''.

is whats popping out the script debug channel trying to track it down but in massive list of 20/ 21 UUIDs may take some time to find the problem
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 09:35
for( ; gSoundIx < llGetListLength(song1); gSoundIx++)


with these changes added inside of the these it doesnt work

if(str == song1)
if(str == song2)

are listeners llLinkedMessage from the controller script to perform the taskes they specifically listen for the menu telling them you just selected one of the two tracks in this case song 1 is U2 Sweetest thing , second track is Linkin Park - Numb that i had uploaded only changed the name in the script so people wouldnt know what was comming from me if they happen to buy my products but since this is having bugs are us no point in hiding it.

now with the for( ; gSoundIx < llGetListLength(song1); gSoundIx++) added directly under these two lines it does nothing at all doesnt even send a signal i just put in to the LCD panel of the music player im doing to change the texture to the song currently playing

i can provide this welcome sound UUID but when the menu dialog is clicked those two listeners listen for its command and when pressed there ment to play the music in the UUID sections and im on the verge even more now of deleting the 5 scripts in total for this products because i dont think matter how much i try to say whats wrong i dont think im making much sense


and if you remove those lines you added just under both those link listeners i get

Could not find sound ''.

cant see any problem with the UUID listings or the way the sound is being called :(

what i will do is PM you the code that i got in world right now without changes in and a couple of sound UUID to test with nothing major but enough to see if you can diagnose the problems as for the menu driven script just whip up menu driven dialog controller that will send a link message to the recievers in the PM for testing :)


EDIT

i will whip up a basic dialog controller script with bare knuckles so it just sends the message down the link set to trigger and post it up bare with me lol
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 10:05
PM sent you to has a quick nasty but working menu controller to kick the script with problems in the backside along with couple of UUID to test the script with hope that helps in diagnosing my frankensteins a little easier
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 11:43
if any body else feels they can help use this dialog menu skeleton to send the song1 song 2 info to the other script that isnt working



CODE

list Main = ["Song1","Song2"];
integer MCHANNEL = 17;

default
{
state_entry()
{
llListen(MCHANNEL,"",llGetOwner(),"");
}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llGetOwner(), "Main Menu", Main, MCHANNEL);
}

{
}
}
listen(integer channel, string name, key id, string message)
{
if(id == llGetOwner())
{
}
if(message == "Song1")
{
llMessageLinked(LINK_SET, 0, "song1", NULL_KEY);
}
if(message == "Song2")
{
llMessageLinked(LINK_SET, 0, "song2", NULL_KEY);
}
}




changed(integer mask)
{
if(mask & CHANGED_OWNER)
{
llResetScript();
}
}
}


b03a3043-0143-71e8-c8e7-1731abae6719 - may use this UUID for the purpose of testing the music player script its a simple less than a second female voice saying welcome i hope some one around is able to help a little more debug my music player script :(
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-26-2008 13:05
OK I tested this in world and it works fine for me
Notes:
I included your menu into the main script, if you have a reason to keep it separate then fine, I left the llMessageLinked portion in place so that you could easily separate it. I also saw no need for 2 sets of if statements as you were looking at the same strings in each.
the one change I made is the gSoundIx = 0; line as your index was never being reset, I placed it in the Link_message on the assumption that you only want to stop playing if a new selection is made.
Once a sound has started it can not be stopped. as per the WIKI entry "llStopSound will not stop sounds started with llPlaySound. IT does work on llLoopSound, though. - WarKirby Magojiro 05/26/2007" so you may not be able to interrupt a playing song.
I commented out the time routine as I saw no real need for it and it will mess up the index in the play loop. If you did need it then you will have to use separate indexes.

CODE


list Main = ["Song1","Song2","pup","pdown"];
integer MCHANNEL = 17;
list song1= ["d1ff1d57-5223-09ec-c2a6-93bd962deeab","d1ff1d57-5223-09ec-c2a6-93bd962deeab"];
list song2= ["b0108c5d-caa8-03b6-cd23-293da7ee2736","b0108c5d-caa8-03b6-cd23-293da7ee2736"];
integer gSoundIx;
float timer_interval = 8.9;


default
{
changed(integer mask)
{
if(mask & CHANGED_OWNER)
{
llResetScript();
}
}
state_entry()
{
llListen(MCHANNEL,"",llGetOwner(),"");
llSetSoundQueueing(TRUE);
//llSetTimerEvent(timer_interval);
}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llGetOwner(), "Main Menu", Main, MCHANNEL);
}

}
listen(integer channel, string name, key id, string message)
{
// if(message == "Song1")
// {
llMessageLinked(LINK_SET, 0, message, NULL_KEY);
// }
// if(message == "Song2")
// {
// llMessageLinked(LINK_SET, 0, "song2", NULL_KEY);
// }
}

link_message(integer sender_num, integer num, string str, key id)
{
gSoundIx = 0;
if(str == "pup")
{
llOwnerSay("Powering Up... Please Wait..");
for( ; gSoundIx < llGetListLength(song1); gSoundIx++)
{
llPreloadSound(llList2String(song1, gSoundIx));
}
for( ; gSoundIx < llGetListLength(song2); gSoundIx++)
{
llPreloadSound(llList2String(song2, gSoundIx));
}
llOwnerSay("Finished Powering Up.... Ready..");
}
if(str == "Song1")
{
for( ; gSoundIx < llGetListLength(song1); gSoundIx++)
{
llPlaySound(llList2String(song1, gSoundIx),1);
}
}
if(str == "Song2")
{
for( ; gSoundIx < llGetListLength(song2); gSoundIx++)
{
llPlaySound(llList2String(song2, gSoundIx),1);
}
}
if(str == "pdown")
{
llOwnerSay("Powering Down....");
}
}
timer()
{
if ( ++gSoundIx < llGetListLength(song1) )
{
llPreloadSound(llList2String(song1, gSoundIx));
}
if ( ++gSoundIx < llGetListLength(song2) )
{
llPreloadSound(llList2String(song2, gSoundIx));
}
else
{

}
}
}

Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
08-26-2008 22:49
thank you worked a treat i can adapt it from here to do exactly what i need to now :) made me a happy person lol no more hair tearing :)