I am trying to create a DJing program in which one song starts when a sprite is clicked and another song starts (and the first one stops) when a second sprite is clicked. My solution has been to create a variable and use it as an on/off boolean, however the first song continues when the second song is activated. The code for the other sprite is the same with the variables changed.
Asked
Active
Viewed 220 times
1

2OL1
- 87
- 7
-
2Is this song the only audio you have running? You could do `when this sprite clicked: [stop all sounds] [start sound for this sprite]` for both sprites. As far as I know, `stop this script` isn't going to stop the sound triggered by the script but it looks like you can use [`set volume to 0%` per sprite or clone](https://scratch.mit.edu/discuss/topic/97954/?page=1#post-847718). See also [1](https://scratch.mit.edu/discuss/topic/245081/?page=1#post-2508809) [2](https://scratch.mit.edu/discuss/m/topic/245143/) – ggorlen Nov 07 '20 at 20:38
2 Answers
1
I misstated the question: I'd actually like to keep one song playing (even if the other song is activated) until the related sprite (button) is clicked again. But using the suggestion of 'set volume to 0%' I was able to create this solution:

2OL1
- 87
- 7
0
In fact you need no boolean. For first sprite the code is
When sprite clicked
stop all sounds
start sound (whatever sound you have)
For other sprite you do the same thing

Coder2195
- 268
- 2
- 13