Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Shuffle Button for playlist
- FireStrong
- Scratcher
20 posts
Shuffle Button for playlist
I am trying to make a project that includes a random shuffle button for a music playlist. I tried, but I couldn't come up with a way to make it work. Can anyone help me, if it is possible? thx.
- Unridicable
- New to Scratch
6 posts
Shuffle Button for playlist
Make 2 lists: one for the playlist and one for all the songs. Do repeat length “all songs” {add ((random) of all songs) to playlist}
Hope this helps!
Hope this helps!
- Astudios
- Scratcher
100+ posts
Shuffle Button for playlist
Say you have 5 songs, create a variable and then do this
use this script
when green flag clickedWhen it says pick random 1 to 5
set [The variable v] to [ (pick random (1) to (5))]
if <[The variable] = [1]> then
play sound [song 1 v]
end
And so on ^
use this script
(pick random (1) to (5))
Last edited by Astudios (March 7, 2016 02:32:40)
- Scratch-Minion
- Scratcher
1000+ posts
Shuffle Button for playlist
Randomly Shuffle A List (How To: Fisher-Yates) on Scratch
https://scratch.mit.edu/projects/11888022/
This is a reference to a program on Scratch that shuffles a list.
(Search for “shuffle” in the “Explore” tab and for me it was the first project that came up.
I used it in my game “Minion Memory” and it works well.
https://scratch.mit.edu/projects/11888022/
This is a reference to a program on Scratch that shuffles a list.
(Search for “shuffle” in the “Explore” tab and for me it was the first project that came up.
I used it in my game “Minion Memory” and it works well.
Last edited by Scratch-Minion (Oct. 2, 2021 06:56:52)
- asivi
- Scratcher
1000+ posts
Shuffle Button for playlist
If all sound files are in the same sprite or in the backdrop
play sound (pick random (1) to (here the amount of sounds you have)) until doneGreets.
- FireStrong
- Scratcher
20 posts
Shuffle Button for playlist
I don't want a song to repeat unil all of the songs play.
- Scratch-Minion
- Scratcher
1000+ posts
Shuffle Button for playlist
The Shuffle Algorithm I suggested shuffles all your songs in your original list into a random order.
If you don't want to shuffle your original song list:
Set “i” to the length of your list.
Put the numbers 1 to i into another list, maybe called “Shuffle List”
Then use the Shuffle Algorithm to shuffle “Shuffle List”.
(If “i” was 10, you will now have a list something like 3,10,1,5,8,6,4,7,2,9)
Now the numbers in this list “Shuffle List” give you a random play order you can use as below:
Set “Num” to 1
Repeat “i”
“NumSongToPlay” = item “Num” of “Shuffle List”
The song you want to play is: item “NumSongToPlay” of “The Name of Your Song List goes here”
Change “Num” by 1
If you don't want to shuffle your original song list:
Set “i” to the length of your list.
Put the numbers 1 to i into another list, maybe called “Shuffle List”
Then use the Shuffle Algorithm to shuffle “Shuffle List”.
(If “i” was 10, you will now have a list something like 3,10,1,5,8,6,4,7,2,9)
Now the numbers in this list “Shuffle List” give you a random play order you can use as below:
Set “Num” to 1
Repeat “i”
“NumSongToPlay” = item “Num” of “Shuffle List”
The song you want to play is: item “NumSongToPlay” of “The Name of Your Song List goes here”
Change “Num” by 1
- deck26
- Scratcher
1000+ posts
Shuffle Button for playlist
Better to start your own topic and share what you have. I cant doplaysound(item X of X)
- PNguyen4649
- Scratcher
1 post
Shuffle Button for playlist
You need to put a play sound button until done then a pick random 1 to ( how many songs you have)
- Swede4
- Scratcher
1 post
Shuffle Button for playlist
Hey, how do I make my music automatically randomize the sound and play the song, for each song I add. Picture of the code block process would be nice. Thanks
- Madcatofdoom
- Scratcher
500+ posts
Shuffle Button for playlist
Please make your own topic instead. Hey, how do I make my music automatically randomize the sound and play the song, for each song I add. Picture of the code block process would be nice. Thanks
Center tags are noice!
Oh, and did you know the color of this line of text is called skyblue?
I *love* formating!
The ST are evil dictators that harvest waffles from the users of Scratch.
And, how did you see this part? Ctrl-Shift-Down? Probably.
Be moist
;
- tpcarfan
- Scratcher
2 posts
Shuffle Button for playlist
Here is my method:
repeat (length of [my list] :: list)most of the other methods they posted would most of the time play the same song more than once & some not at all.
set [random number] to (pick random (1) to (length of [my list] :: list)
add (item (random number) of [my list to be shuffled] :: list) to [my list]
delete (item (random number) of [my list to be shuffled] :: list) of [my list])
end
Last edited by tpcarfan (Dec. 14, 2022 21:17:41)
- dmblair1
- Scratcher
3 posts
Shuffle Button for playlist
I'm not sure if the Scratch update changed this code, but I can't seem to replicate it. Here is my method:repeat (length of [my list] :: list)most of the other methods they posted would most of the time play the same song more than once & some not at all.
set [random number] to (pick random (1) to (length of [my list] :: list)
add (item (random number) of [my list to be shuffled] :: list) to [my list]
delete (item (random number) of [my list to be shuffled] :: list) of [my list])
end
Any ideas?
- coIIide
- Scratcher
100+ posts
Shuffle Button for playlist
Please make your own topic, this is a seven year old topic, and try not to necropost again.I'm not sure if the Scratch update changed this code, but I can't seem to replicate it. Here is my method:repeat (length of [my list] :: list)most of the other methods they posted would most of the time play the same song more than once & some not at all.
set [random number] to (pick random (1) to (length of [my list] :: list)
add (item (random number) of [my list to be shuffled] :: list) to [my list]
delete (item (random number) of [my list to be shuffled] :: list) of [my list])
end
Any ideas?
hello
this is my signature, it pops up under every post i make :)
- Discussion Forums
- » Help with Scripts
- » Shuffle Button for playlist