Closed axobeast2020 closed 4 years ago
Use songPlayer.setPlaying(false);
It`s not work
Could you be more specific? This code stops the SongPlayer from playing.
Im sorry for long waiting. I have this code: Song song = NBSDecoder.parse(new File(musicmaster.getDataFolder()+File.separator+"AKindofMagic.nbs")); Playlist playlist = new Playlist(song); RadioSongPlayer rsp = new RadioSongPlayer(playlist); // Add player to SongPlayer so he will hear the song. rsp.addPlayer((Player) sender); String name = rsp.getSong().getTitle(); // Start RadioSongPlayer playback rsp.setPlaying(enabled);, where enabled - is boolean variable. When I want to stop song, I set value of the "enabled" to "false" in "/stop" command, but it
s not work, song play.
OOPS! Code:
Song song = NBSDecoder.parse(new File(musicmaster.getDataFolder()+File.separator+"AKindofMagic.nbs")); Playlist playlist = new Playlist(song); RadioSongPlayer rsp = new RadioSongPlayer(playlist); // Add player to SongPlayer so he will hear the song. rsp.addPlayer((Player) sender); String name = rsp.getSong().getTitle(); // Start RadioSongPlayer playback rsp.setPlaying(enabled);
It doesn't matter whether you use variable or boolean directly in rsp.setPlaying(boolean)
. You still have to call it again. Add rsp.setPlaying(false);
to your /stop
command.
I've been trying to solve the problem with "stop song" for the past few days. I'm trying anyway: ``` public class rounds{
Song song = NBSDecoder.parse(new File(musicmaster.getDataFolder()+File.separator+"AKindofMagic.nbs"));
Playlist playlist = new Playlist(song);
public void starting(Player sender) {
RadioSongPlayer rsp = new RadioSongPlayer(playlist);
rsp.addPlayer(sender);
rsp.setPlaying(true);
}
public void stop(Player sender) {
RadioSongPlayer rsp = new RadioSongPlayer(playlist);
rsp.setPlaying(false);
}
}
I'm trying anyway: `public class rounds{
Song song = NBSDecoder.parse(new File(musicmaster.getDataFolder()+File.separator+"AKindofMagic.nbs"));
Playlist playlist = new Playlist(song);
RadioSongPlayer rsp = new RadioSongPlayer(playlist);
public void starting(Player sender) {
rsp.addPlayer(sender);
rsp.setPlaying(true);
}
public void stop(Player sender) {
rsp.setPlaying(false);
}
}
I'm trying anyway:
public class rounds{
public void starting(Player sender) {
Song song = NBSDecoder.parse(new File(musicmaster.getDataFolder()+File.separator+"AKindofMagic.nbs"));
Playlist playlist = new Playlist(song);
RadioSongPlayer rsp = new RadioSongPlayer(playlist);
rsp.addPlayer(sender);
rsp.setPlaying(true);
}
public void stop(Player sender) {
Song song = NBSDecoder.parse(new File(musicmaster.getDataFolder()+File.separator+"AKindofMagic.nbs"));
Playlist playlist = new Playlist(song);
RadioSongPlayer rsp = new RadioSongPlayer(playlist);
rsp.removePlayer(sender);
rsp.destroy();
rsp.setPlaying(false);
}
}`
Аnd many more different options Nothing works, the melody just doesn't turn off. help, can you offer an example of the code that allows you to turn off the ringtone?
I'm just crying because I can't turn off this stupid tune
The second way you sent me is the only one of these three which may work. Do you have Discord? If so please send me a message there. I would me able to help you more interactively. My id is koca2000#6469. It seems like you don't really understand how object in Java works.
Yes, I'm really new to java. But, I'm sorry i don't have discord.
Nevermind. You are creating an object of type RadioSongPlayer
. Imagine that it is physical radio on your desk. Every time you call new RadioSongPlayer()
it is like when you buy a brand new radio from shop. Now if you turn on one radio and then you want to turn it off, you have to turn off the same piece of radio that you turned on before. It is absolutely same with objects in java. When you want to turn off the radio, you have to have it stored in some variable from the time you turned it on and call the setPlaying
method on the same object.
Yes, I managed to stop the song. Thank you very much! The topic can be closed!
I know, how can i start playing noteblocks song, but how stop this Sony? Help me, please.