Browse Source

Tweaks to audio docs

pull/867/head
Joe4evr 7 years ago
parent
commit
0ea2f853d9
3 changed files with 12 additions and 11 deletions
  1. +4
    -5
      docs/guides/voice/samples/audio_create_ffmpeg.cs
  2. +7
    -5
      docs/guides/voice/samples/audio_ffmpeg.cs
  3. +1
    -1
      docs/guides/voice/samples/joining_audio.cs

+ 4
- 5
docs/guides/voice/samples/audio_create_ffmpeg.cs View File

@@ -1,11 +1,10 @@
private Process CreateStream(string path) private Process CreateStream(string path)
{ {
var ffmpeg = new ProcessStartInfo
return Process.Start(new ProcessStartInfo
{ {
FileName = "ffmpeg", 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, UseShellExecute = false,
RedirectStandardOutput = true, RedirectStandardOutput = true,
};
return Process.Start(ffmpeg);
}
});
}

+ 7
- 5
docs/guides/voice/samples/audio_ffmpeg.cs View File

@@ -1,9 +1,11 @@
private async Task SendAsync(IAudioClient client, string path) private async Task SendAsync(IAudioClient client, string path)
{ {
// Create FFmpeg using the previous example // 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(); }
}
} }

+ 1
- 1
docs/guides/voice/samples/joining_audio.cs 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. // For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
var audioClient = await channel.ConnectAsync(); var audioClient = await channel.ConnectAsync();
}
}

Loading…
Cancel
Save