Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not streaming audio on ubuntu 16.04 #78

Open
timoheijne opened this issue Feb 19, 2017 · 5 comments
Open

Not streaming audio on ubuntu 16.04 #78

timoheijne opened this issue Feb 19, 2017 · 5 comments

Comments

@timoheijne
Copy link

timoheijne commented Feb 19, 2017

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?

@Edsardio
Copy link

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

@timoheijne
Copy link
Author

@kesbookuk
Copy link

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

@timoheijne
Copy link
Author

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

@kesbookuk
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants