Tweaks to audio docs (#867)

* Tweaks to audio docs

* Make it more obvious that -1 means infinity
This commit is contained in:
Joe4evr
2017-11-06 04:06:28 +01:00
committed by Christopher F
parent da335b95c4
commit e30fd29085
4 changed files with 14 additions and 12 deletions

View File

@@ -1,11 +1,10 @@
private Process CreateStream(string path)
{
var ffmpeg = new ProcessStartInfo
return Process.Start(new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $"-i {path} -ac 2 -f s16le -ar 48000 pipe:1",
Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1",
UseShellExecute = false,
RedirectStandardOutput = true,
};
return Process.Start(ffmpeg);
}
});
}

View File

@@ -1,9 +1,11 @@
private async Task SendAsync(IAudioClient client, string path)
{
// Create FFmpeg using the previous example
var ffmpeg = CreateStream(path);
var output = ffmpeg.StandardOutput.BaseStream;
var discord = client.CreatePCMStream(AudioApplication.Mixed);
await output.CopyToAsync(discord);
await discord.FlushAsync();
using (var ffmpeg = CreateStream(path))
using (var output = ffmpeg.StandardOutput.BaseStream)
using (var discord = client.CreatePCMStream(AudioApplication.Mixed))
{
try { await output.CopyToAsync(discord); }
finally { await discord.FlushAsync(); }
}
}

View File

@@ -7,4 +7,4 @@ public async Task JoinChannel(IVoiceChannel channel = null)
// For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
var audioClient = await channel.ConnectAsync();
}
}