discordie icon indicating copy to clipboard operation
discordie copied to clipboard

Not streaming audio on ubuntu 16.04

Open timoheijne opened this issue 8 years ago • 5 comments

Hello,

I am attempting to make a soundbot (partially using this to get into node) however, I am trying to upload my bot to my ubuntu server and it will not play sounds it'll simply join and leave a second later. While on my windows computer it works well.

Node version: v6.9.5 Ffmpeg Version: 2.8.11-0ubuntu0.16.04.1 Discordie Version: Stable Branch

This is the code I am using for streaming the sound (Used the example for ffmpeg)

function playSound(input, soundPath) {
  	var voice = input.member.getVoiceChannel();
	if(voice == null) {
		input.reply("I can't find your voice channel. Make sure you are in one to begin with...");
		return;
	}

  	voice.join(false, false).then(info => {
  		voiceConnection = info.voiceConnection;
    	console.log("Received Sound file: " + soundPath);
						
		var encoder = info.voiceConnection.createExternalEncoder({
		    type: "ffmpeg",
		    source: soundPath
		});
		if (!encoder) return console.log("Voice connection is no longer valid");

		encoder.once("end", () => { 
			info.voiceConnection.disconnect(); 
			voiceConnection = null; 
		});

		var encoderStream = encoder.play();
		console.log("File dispatched.");
		encoderStream.resetTimestamp();
		encoderStream.removeAllListeners("timestamp");
		encoderStream.on("timestamp", time => console.log("Time " + time));
	});
}

So as is my question is there something wrong with this that its "Windows only" Or do i have to install something else on my server for that work too?

timoheijne avatar Feb 19 '17 20:02 timoheijne

To start off with, have you installed FFMPEG on your ubuntu server?

Edsardio avatar Feb 19 '17 21:02 Edsardio

@Edsardio Yes, http://prntscr.com/eaummk

timoheijne avatar Feb 19 '17 21:02 timoheijne

Are you using this for a website or a discord bot because of your using this for a website it won't work at all is for discord not for a website @ighenk

kesbookuk avatar Mar 01 '17 14:03 kesbookuk

@kesbookuk I am using this for a discord bot. The problem is that it would simply join the discord channel and leave a second later on an ubuntu server while if i run the bot via my windows computer it would join the channel and play the sound properly and leave when its done.

timoheijne avatar Mar 01 '17 16:03 timoheijne

@ighenk looks like errors in the code I will send a fixed version

kesbookuk avatar Apr 03 '17 14:04 kesbookuk