Skip to content

Playing songs

koca2000 edited this page Apr 15, 2018 · 6 revisions

SongPlayer types

There are 3 types of SongPlayer:

RadioSongPlayer

Play song for all added players no matter where they are.

Song song; // Preloaded song
// Create RadioSongPlayer.
RadioSongPlayer rsp = new RadioSongPlayer(song);
// Add player to SongPlayer so he will hear the song.
rsp.addPlayer(Player);
// Start RadioSongPlayer playback
rsp.setPlaying(true);

PositionSongPlayer

Play song for all added players in specified range from specified point.

Song song; // Preloaded song
// Create PositionSongPlayer.
PositionSongPlayer psp = new PositionSongPlayer(song);
// Set location where the song will be playing
psp.setTargetLocation(Location);
// Set distance from target location in which will players hear the SongPlayer
psp.setDistance(16); // Default: 16
// Add player to SongPlayer so he will hear the song.
psp.addPlayer(Player);
// Start RadioSongPlayer playback
psp.setPlaying(true);

NoteBlockSongPlayer

Play song for all added players in specified range from specified point.

Song song; // Preloaded song
// Create NoteBlockSongPlayer.
NoteBlockSongPlayer nbsp = new NoteBlockSongPlayer(song);
// Set block where the song will be playing
nbsp.setNoteBlock(Block);
// Set distance from target location in which will players hear the SongPlayer
nbsp.setDistance(16); // Default: 16
// Add player to SongPlayer so he will hear the song.
nbsp.addPlayer(Player);
// Start RadioSongPlayer playback
nbsp.setPlaying(true);

Clone this wiki locally