Jhawsh
Jhawsh
DIAdiscord.js - Imagine an app
Created by Jhawsh on 3/28/2024 in #djs-voice
Audio Resources immediately goes from "playing" to "idle" despite having NoSubscriberBehavior.Play
For future reference whoever may come across this, I was having issue with the implementation of
createAudioResource('http://radio.truckers.fm/radio-ogg', {
inputType: StreamType.OggOpus,
});
createAudioResource('http://radio.truckers.fm/radio-ogg', {
inputType: StreamType.OggOpus,
});
and ended up subsituting it for
const stream = got.stream("http://radio.truckers.fm/radio-ogg");
let resource = createAudioResource(stream);
const stream = got.stream("http://radio.truckers.fm/radio-ogg");
let resource = createAudioResource(stream);
Both impl worked locally but something in the server environment must of been having issues.
8 replies
DIAdiscord.js - Imagine an app
Created by Jhawsh on 3/28/2024 in #djs-voice
Audio Resources immediately goes from "playing" to "idle" despite having NoSubscriberBehavior.Play
I am able to use ffmpeg -i http://radio.truckers.fm/radio-ogg -c copy test.ogg to output the stream to an ogg file. Its also accesible via ssh by just typing 'ffmpeg'. Unless it needs to be put anywhere special for discordjs to pick it up
8 replies
DIAdiscord.js - Imagine an app
Created by Jhawsh on 3/28/2024 in #djs-voice
Audio Resources immediately goes from "playing" to "idle" despite having NoSubscriberBehavior.Play
const { createAudioResource, createAudioPlayer, StreamType, NoSubscriberBehavior } = require('@discordjs/voice');

const resource = createAudioResource('http://radio.truckers.fm/radio-ogg', {
inputType: StreamType.OggOpus,
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
},
});

player.on('error', error => {
console.error('Error:', error.message);
});

resource.playStream.on('error', error => {
console.error('Error:', error.message);
});

player.play(resource);

module.exports = {player, resource};
const { createAudioResource, createAudioPlayer, StreamType, NoSubscriberBehavior } = require('@discordjs/voice');

const resource = createAudioResource('http://radio.truckers.fm/radio-ogg', {
inputType: StreamType.OggOpus,
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
},
});

player.on('error', error => {
console.error('Error:', error.message);
});

resource.playStream.on('error', error => {
console.error('Error:', error.message);
});

player.play(resource);

module.exports = {player, resource};
Here is the exact code which runs locally fine, but on a hosted server does not play anything. The voice channel joining code is here (it does join the channel fine)
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator
});

connection.subscribe(player.player);

connection.on(VoiceConnectionStatus.Disconnected, async (oldState, newState) => {
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch (error) {
// Seems to be a real disconnect which SHOULDN'T be recovered from
connection.destroy();
}
});
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator
});

connection.subscribe(player.player);

connection.on(VoiceConnectionStatus.Disconnected, async (oldState, newState) => {
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch (error) {
// Seems to be a real disconnect which SHOULDN'T be recovered from
connection.destroy();
}
});
I've disabled the firewall on the server to rule that out.
8 replies
DIAdiscord.js - Imagine an app
Created by Jhawsh on 3/28/2024 in #djs-voice
Audio Resources immediately goes from "playing" to "idle" despite having NoSubscriberBehavior.Play
I just removed url, but I am 100% sure the stream works, (I've tried with OggOpus and the ogg streaming link). The implementation actually works fine locally (and on a different hosted server), but for some reason on my new host doesn't work. My only thoughts is it could be something to do with the firewall, but I am not seeing anything suggesting that in the debug/errors
8 replies
DIAdiscord.js - Imagine an app
Created by Jhawsh on 3/28/2024 in #djs-voice
Audio Resources immediately goes from "playing" to "idle" despite having NoSubscriberBehavior.Play
const { createAudioResource, createAudioPlayer, StreamType, NoSubscriberBehavior } = require('@discordjs/voice');

const resource = createAudioResource('https://mp3stream.co', {
inputType: StreamType.Opus,
});

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
},
});

player.on('error', error => {
console.error('Error:', error.message);
});

player.on('debug', error => {
console.error('Debug:', error);
});


resource.playStream.on('error', error => {
console.error('Error:', error.message);
});

player.play(resource);

module.exports = {player, resource};
const { createAudioResource, createAudioPlayer, StreamType, NoSubscriberBehavior } = require('@discordjs/voice');

const resource = createAudioResource('https://mp3stream.co', {
inputType: StreamType.Opus,
});

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
},
});

player.on('error', error => {
console.error('Error:', error.message);
});

player.on('debug', error => {
console.error('Debug:', error);
});


resource.playStream.on('error', error => {
console.error('Error:', error.message);
});

player.play(resource);

module.exports = {player, resource};
8 replies