No audio is played... #68
-
class InternalMusic {
var playerManager: AudioPlayerManager = DefaultAudioPlayerManager()
var player: AudioPlayer = playerManager.createPlayer()
var videoid: String = ""
fun setVideoID(videoid: String) {
this.videoid = videoid
}
fun init() {
playerManager.registerSourceManager(YoutubeAudioSourceManager(true, "myemail", "mypassword"))
AudioSourceManagers.registerRemoteSources(playerManager)
}
fun play() {
playerManager.loadItem(videoid,
object : AudioLoadResultHandler {
override fun trackLoaded(track: AudioTrack) {
player.playTrack(track)
}
override fun playlistLoaded(playlist: AudioPlaylist) {
for (track in playlist.tracks) {
player.playTrack(track)
}
}
override fun noMatches() {
println("No Matches for $videoid")
}
override fun loadFailed(throwable: FriendlyException) {
println("Unable to load $videoid")
}
})
}
fun stop() { player.stopTrack() }
fun pause() { player.setPaused(true) }
fun resume() { player.setPaused(false) }
fun volume(volume: Int) { player.volume = volume }
} i call
and output is:
no audio is played. what am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
freyacodes
Jan 9, 2024
Replies: 1 comment 2 replies
-
What were you expecting to happen? Audio out of your speaker? Audio out of your Discord bot? Your code does not make use of the audio frames that Lavaplayer is producing. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an example of how you can play audio to your speakers with an
AudioPlayer
https://github.com/lavalink-devs/lavaplayer/blob/cbc0225/testbot/src/main/java/com/sedmelluq/discord/lavaplayer/demo/LocalPlayerDemo.java#L47-L60