#play mp3

13 messages · Page 1 of 1 (latest)

pallid glen
#

Hello i need to play mp3 file and i cant , it gives error

        try{
            const resource = createAudioResource('audio/qmd.mp3');
            player.play(resource);

            connection1.subscribe(player);
            connection2.subscribe(player);
        }
        catch (error) {
            interaction.reply('MP3 File not Found.')
        }
    }```
old cairn
#

• 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.

pallid glen
#

Discord.js v14.7.1
Node v18.15.0

reef stone
#

have you tried with absolute path to the mp3 audio?

#

and what is the error?

silent tiger
#

You have to run player.play() after connection.subscribe()

#

Else it's like saying "let me play audio and after it's been played I plug in my headphones"

#

Just for reference ;)

#

That's at least what I once saw in a stackoverflow issue. If that and the other solution doesn't work, I'd check what happens with the connections through the stateChange event for example and make sure the intents are all correctly set up

late fjord
#

and make sure to update #announcements

silent tiger
#

Good point too

viscid oriole
#

would be really useful if you shared the error you are actually getting

silent tiger
#

Oh I read that it doesn't throw in error