Author Topic: How to play music on a random loop?  (Read 4118 times)

Kronos

  • Guest
How to play music on a random loop?
« on: January 03, 2017, 03:33:21 AM »
Hi,

I have created a voice command to initiate voice attack to play music when i request a certain genre and this works fine.

What i would like to know is how i get it to keep playing the entire folder of music (not just one track which it is currently doing), from one command, without stopping and without me having to request a further command.  At the moment it will play one song and stop, i have to repeat the request if i want it to play another - I assume this might have something to do with a loop but have no idea where to begin with loops (i had a look and don't understand how they would work in this scenario)... Screen shots attached. Thx in advance.

Ben

J. Calvert (Joshua)

  • Newbie
  • *
  • Posts: 30
Re: How to play music on a random loop?
« Reply #1 on: January 03, 2017, 06:13:33 AM »
Here's something you could try:
Alter Exploration music please to:
Code: [Select]
Set Boolean [musicloop] to True
Start Loop While : [musicloop] Equals True
    Play random sound (from directory: U:\Itunes\Music\Bob Dylan\Dylan)
End Loop

Don't forget to check the "Wait until sound completes before continuing command" in the Play random sound command or else all the files will start to play at once.

Make a new command Stop exploration music:
Code: [Select]
Set Boolean [musicloop] to False
Kill command, 'Exploration music please'

My first attempt was to use Stop Sounds instead of Kill command "Exploration music" but that doesn't seem to work. It doesn't stop the current playing soundfile but finishes it first and then stops the loop.
The kill command finishes the loop and the current soundfile stops at once.

Kronos

  • Guest
Re: How to play music on a random loop?
« Reply #2 on: January 03, 2017, 08:07:12 PM »
Here's something you could try:
Alter Exploration music please to:
Code: [Select]
Set Boolean [musicloop] to True
Start Loop While : [musicloop] Equals True
    Play random sound (from directory: U:\Itunes\Music\Bob Dylan\Dylan)
End Loop

Don't forget to check the "Wait until sound completes before continuing command" in the Play random sound command or else all the files will start to play at once.

Make a new command Stop exploration music:
Code: [Select]
Set Boolean [musicloop] to False
Kill command, 'Exploration music please'

My first attempt was to use Stop Sounds instead of Kill command "Exploration music" but that doesn't seem to work. It doesn't stop the current playing soundfile but finishes it first and then stops the loop.
The kill command finishes the loop and the current soundfile stops at once.

Joshua - worked perfectly. Thank you very much!  :)

I discovered the kill command too, you're absolutely right.