Restructure documentation layout
This commit is contained in:
11
docs/guides/voice/samples/audio_create_ffmpeg.cs
Normal file
11
docs/guides/voice/samples/audio_create_ffmpeg.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
private Process CreateStream(string path)
|
||||
{
|
||||
var ffmpeg = new ProcessStartInfo
|
||||
{
|
||||
FileName = "ffmpeg",
|
||||
Arguments = $"-i {path} -ac 2 -f s16le -ar 48000 pipe:1",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
};
|
||||
return Process.Start(ffmpeg);
|
||||
}
|
||||
9
docs/guides/voice/samples/audio_ffmpeg.cs
Normal file
9
docs/guides/voice/samples/audio_ffmpeg.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
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, 1920);
|
||||
await output.CopyToAsync(discord);
|
||||
await discord.FlushAsync();
|
||||
}
|
||||
10
docs/guides/voice/samples/joining_audio.cs
Normal file
10
docs/guides/voice/samples/joining_audio.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
[Command("join")]
|
||||
public async Task JoinChannel(IVoiceChannel channel = null)
|
||||
{
|
||||
// Get the audio channel
|
||||
channel = channel ?? (msg.Author as IGuildUser)?.VoiceChannel;
|
||||
if (channel == null) { await msg.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be passed as an argument."); return; }
|
||||
|
||||
// For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
|
||||
var audioClient = await channel.ConnectAsync();
|
||||
}
|
||||
Reference in New Issue
Block a user