#autopause after playing state on audio player.

4 messages · Page 1 of 1 (latest)

quick furnace
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

orchid torrent
#
    initAudioPlayer(): void{
        if (this.audioPlayer instanceof AudioPlayer) this.audioPlayer.stop(true);
        delete this.audioPlayer;
        this.audioPlayer = createAudioPlayer({
            /*behaviors: { // NOTE THIS IS NOT THE `autopause` PROBLEM..
                noSubscriber: NoSubscriberBehavior.Pause,
            },*/
        });
        this.audioPlayer.on(AudioPlayerStatus.Playing, () => {
            this.playing = true;
        });
        this.audioPlayer.on(AudioPlayerStatus.Paused, () => {
            this.playing = false;
        });
        this.audioPlayer.on(AudioPlayerStatus.AutoPaused, () => {
            console.log("autopaused")
            this.playing = false;
        });
        this.audioPlayer.on("error", (err) => {
            this.playing = false;
            this.playNext();
            // @ts-ignore
            logger.error('Error:', err.message, 'with track', err.resource.metadata.title)
        });
        this.audioPlayer.on('stateChange', (oldState, newState) => {
            logger.debug(`[AudioPlayer]: Audio player transitioned from ${oldState.status} to ${newState.status}`);
        });
    }
#
    joinVC(): void{
        logger.debug("[AudioPlayer][Connection]: Trying to connect to channel..");
        this.connection = joinVoiceChannel({
            channelId: this.channel.id,
            guildId:  this.channel.guild.id,
            adapterCreator: this.channel.guild.voiceAdapterCreator,
            selfDeaf: true,
            selfMute: false,
            debug: true,
        });
        logger.debug("[AudioPlayer][Connection]: Trying to subscribe with AudioPlayer..");
        this.audioPlayerSubscription = this.connection.subscribe(this.audioPlayer);
        logger.debug("[AudioPlayer][Connection]: " + (this.audioPlayerSubscription ? "subscribed!" : "Error while subscribing!"));

        this.connection.on(VoiceConnectionStatus.Ready, (oldState, newState) => {
            logger.debug('[AudioPlayer][Connection]: Ready state!'); // NOTE: This will not called, idk why?
        });

        this.audioPlayer.on(AudioPlayerStatus.Playing, (oldState, newState) => {
            logger.debug('[AudioPlayer]: Audio player is in the Playing state!');
        });
        this.connection.on("stateChange", (oldState, newState) => {
            logger.debug(`[AudioPlayer][Connection]: Connection transitioned from ${oldState.status} to ${newState.status}`);
        });
    }