Jump to content
ainst Composer

Want to create music player script

Recommended Posts

Posted (edited)

Hello! I need to create a script that allows to loop a 10 seconds sound clip from the UUIDs list in the script (or one notecard). and to switch to the next loop when clicked, (please, note - not full song player - only one 10 seconds loop) with the ability to turn on / off.

any suggestions?

Scheme, how i see it:

start

list:

bananas - uuid1, vol 1.0;

madonna - uuid2, vol 1.0;

...

jackson - uuid3, vol 1.0;

on/off ?;

if touched loop next uuid;

end.

Yes, I already asked and really hate to do this, but now I decided to try to create my own script, because I did not find a suitable one from the existing ones.

Edited by ainst Composer

Share this post


Link to post
Share on other sites
Posted (edited)

Something like... (untested)

integer count;
list songs = [uuid#1, uuid#2, etc etc];
default
{
    touch_start(integer total_number)
    {   llLoopSound( llList2Key(sounds,count), 0.5 );
        ++count;     

     count %= llGetListLength(sounds);
    }
}

Edited by Xiija
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Xiija said:

Something like... (untested)

integer count;
list songs = [uuid#1, uuid#2, etc etc];
default
{
    touch_start(integer total_number)
    {   llLoopSound( llList2Key(sounds,count), 0.5 );
        ++count;     

     count %= llGetListLength(sounds);
    }
} 

Thanks very much for your answer! You are awesome!


integer count;
list songs = [
"6aa62a53-b504-ac84-f045-c635872487ce", 
"79e5c392-acf3-94fe-a311-47bdff2cb511", 
"0ff6b5fd-ae86-6980-8bfa-38a93dadd2ab"];
default
{
    touch_start(integer total_number)
    {   llLoopSound( llList2Key(songs,count), 0.5 );
        ++count;     

     count %= llGetListLength(songs);
    }
} 

(Its an example UUIDs)

Edited by ainst Composer

Share this post


Link to post
Share on other sites

Maybe someone knows how to add on and off here? what are the ways? The chat command is more or less clear, but how else?
Say, a long press for three seconds? how to do it?

Share this post


Link to post
Share on other sites

A basic toggle switch just needs a global integer variable that you can use as a Boolean TRUE/FALSE, or ON/OFF switch. Change its polarity every time that you trigger the event that it's in (like your touch_start event) and then take a different action depending on whether your variable is TRUE or FALSE at the time.

As for a long press, there are several ways to do that.  I suggest looking at the LSL wiki entry for llGetTime for inspiration.  Think about the possibility of using a touch_end event as well as a touch_start event, for example.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...