Discuss Scratch

Bellamcintire
Scratcher
71 posts

How do I make a 'Next song' button?

I am trying to make a clicker and want there to be a next song button and I have a total of 11 songs but how do I play the next song?
Lirey
Scratcher
100+ posts

How do I make a 'Next song' button?

this plays the next song in order of the songs in the sound tab
when green flag clicked
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
or would you want the user to be able to pick their next song?
Spentinium
Scratcher
100+ posts

How do I make a 'Next song' button?

when gf clicked
set [is a clone? v] to (0) // for this sprite only
set [current song v] to (0)
set [songs v] to (amount of songs :: grey)
...
broadcast (next song v)

when I receive [next song v]
if <(is a clone?) = (1)> then
delete this clone
end
set [current song v] to (((current song) mod (amount of songs)) + (1))
create clone of (myself v)

when I start as a clone
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done

This code is untested so use it at your own risk.

Last edited by Spentinium (July 17, 2023 18:03:41)

bRuHbRuHmEmEmAn
Scratcher
500+ posts

How do I make a 'Next song' button?

Spentinium wrote:

when gf clicked
set [is a clone? v] to (0) // for this sprite only
set [current song v] to (0)
delete all of [song list v] :: list
add [song 1 name] to [song list v]
add [song 2 name] to [song list v]
...
broadcast (next song v)

when I receive [next song v]
if <(is a clone?) = (1)> then
delete this clone
end
set [current song v] to (((current song) mod (length of [song list v])) + (1))
create clone of (myself v)

when I start as a clone
start sound (item (current song) of [song list v]) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done

This code is untested so use it at your own risk.
They were asking how they could change the song upon a click of a button aswell.
Spentinium
Scratcher
100+ posts

How do I make a 'Next song' button?

bRuHbRuHmEmEmAn wrote:

Spentinium wrote:

when gf clicked
set [is a clone? v] to (0) // for this sprite only
set [current song v] to (0)
delete all of [song list v] :: list
add [song 1 name] to [song list v]
add [song 2 name] to [song list v]
...
broadcast (next song v)

when I receive [next song v]
if <(is a clone?) = (1)> then
delete this clone
end
set [current song v] to (((current song) mod (length of [song list v])) + (1))
create clone of (myself v)

when I start as a clone
start sound (item (current song) of [song list v]) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done

This code is untested so use it at your own risk.
They were asking how they could change the song upon a click of a button aswell.
when this sprite clicked
broadcast (next song v)
medians
Scratcher
1000+ posts

How do I make a 'Next song' button?

Spentinium wrote:

when I start as a clone
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
Isn’t it play sound lol even in 3.0 you colored it for nothing

Last edited by medians (July 17, 2023 18:31:22)

Bellamcintire
Scratcher
71 posts

How do I make a 'Next song' button?

Lirey wrote:

this plays the next song in order of the songs in the sound tab
when green flag clicked
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
or would you want the user to be able to pick their next song?
Okay!
Bellamcintire
Scratcher
71 posts

How do I make a 'Next song' button?

Lirey wrote:

this plays the next song in order of the songs in the sound tab
when green flag clicked
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
or would you want the user to be able to pick their next song?
I just tried it and it works! Tysm!!!
Lirey
Scratcher
100+ posts

How do I make a 'Next song' button?

Bellamcintire wrote:

Lirey wrote:

this plays the next song in order of the songs in the sound tab
when green flag clicked
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
or would you want the user to be able to pick their next song?
I just tried it and it works! Tysm!!!
Great to hear! I'm glad it worked out for you
Spentinium
Scratcher
100+ posts

How do I make a 'Next song' button?

medians wrote:

Spentinium wrote:

when I start as a clone
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
Isn’t it play sound lol even in 3.0 you colored it for nothing
Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization. Scratch promotes computational thinking and problem solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Scratch is always free and is available in more than 70 languages.
medians
Scratcher
1000+ posts

How do I make a 'Next song' button?

Spentinium wrote:

medians wrote:

Spentinium wrote:

when I start as a clone
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
Isn’t it play sound lol even in 3.0 you colored it for nothing
Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization. Scratch promotes computational thinking and problem solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Scratch is always free and is available in more than 70 languages.
medians!!!
ACriticIGuess
Scratcher
16 posts

How do I make a 'Next song' button?

simple.
play sound [song1 v] until done
play sound [song2 v] until done
Spentinium
Scratcher
100+ posts

How do I make a 'Next song' button?

medians wrote:

Spentinium wrote:

medians wrote:

Spentinium wrote:

when I start as a clone
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
Isn’t it play sound lol even in 3.0 you colored it for nothing
Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization. Scratch promotes computational thinking and problem solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Scratch is always free and is available in more than 70 languages.
medians!!!
medians mix-up moment
ducky3624
Scratcher
22 posts

How do I make a 'Next song' button?

This is unbelivible but I tried this and it actually works! but.. it worrks for another random sound sooo this isnt the excact answer but it is very close!

This is the sound code that this strategy only works for

when green flag clicked
broadcast [music]

when I receive [music]
play sound (pick random (1) to (11)) until done
broadcast [music]

now the next sound code!

when I receive [i want next aka another random song]
stop all sounds


pls tell me if it works and if it does then tell me if its fine or not! please quote!
max231354
Scratcher
9 posts

How do I make a 'Next song' button?

why is this old scratch posts?
Bellamcintire
Scratcher
71 posts

How do I make a 'Next song' button?

ducky3624 wrote:

This is unbelivible but I tried this and it actually works! but.. it worrks for another random sound sooo this isnt the excact answer but it is very close!

This is the sound code that this strategy only works for

when green flag clicked
broadcast [music]

when I receive [music]
play sound (pick random (1) to (11)) until done
broadcast [music]

now the next sound code!

when I receive [i want next aka another random song]
stop all sounds


pls tell me if it works and if it does then tell me if its fine or not! please quote!
Okey! Ty
SpyCoderX
Scratcher
1000+ posts

How do I make a 'Next song' button?

ducky3624 wrote:

This is unbelivible but I tried this and it actually works! but.. it worrks for another random sound sooo this isnt the excact answer but it is very close!

This is the sound code that this strategy only works for

when green flag clicked
broadcast [music]

when I receive [music]
play sound (pick random (1) to (11)) until done
broadcast [music]

now the next sound code!

when I receive [i want next aka another random song]
stop all sounds


pls tell me if it works and if it does then tell me if its fine or not! please quote!
Welcome to the Scratch Forums!

You can actually simplify your code to this:
when green flag clicked
forever
play sound (pick random (1) to (10)) until done
end

when I receive [next v]
stop all sounds

Anyway, please don’t reply to old or abandoned posts.
This is known as Necroposting and is considered spam.

Thanks, and have a good day!

Last edited by SpyCoderX (April 21, 2024 23:32:10)

Powered by DjangoBB