public static async Task VoiceStream(VoiceNextConnection vnc, Video vid, int SpecialID) { MusicBot.ThreadIDD = SpecialID; MusicBot.UsersInChannel = DUtils.GetAmountInVoice(vnc.Channel); new Thread((ThreadStart)(() => vnc.VoiceReceived += (AsyncEventHandler <VoiceReceiveEventArgs>)(async e => { if (SpecialID != MusicBot.ThreadIDD) { Thread.CurrentThread.Abort(); } try { if (Config.StopPlayingIfANYsoundIsReceived) { MusicBot.StopPlayingJoined = true; } else { Utils.Debug((object)("Musicbot, Received sounds!!!" + e.User.Username)); } } catch (Exception ex) { if (Config.StopPlayingWithNewPlayer) { MusicBot.StopPlayingJoined = true; } if (!ex.Message.Contains("De objectverwijzing is niet op een exemplaar van een object ingesteld.") || !Config.StopPlayingWithNewPlayer) { return; } MusicBot.StopPlayingJoined = true; } await Task.Delay(1); }))).Start(); Exception exc = (Exception)null; string filename = MusicBot.CreatePathFromVid(MusicBot.FirstPlay()); if (!File.Exists(filename)) { Utils.Log(string.Format("File `{0}` does not exist.", (object)filename), LogType.Error); } else { Exception obj = null; int num = 0; try { try { int SampleRate = 48000; int channelCount = 2; WaveFormat OutFormat = new WaveFormat(SampleRate, 16, channelCount); MediaFoundationResampler resampler; WaveStream mediaStream; try { mediaStream = (WaveStream) new WaveChannel32((WaveStream) new MediaFoundationReader(filename), MusicBot.Volume, 0.0f); WaveStream waveStream = mediaStream; try { MediaFoundationResampler foundationResampler = resampler = new MediaFoundationResampler((IWaveProvider)mediaStream, OutFormat); try { int m = int.Parse(string.Concat((object)mediaStream.Length)); MusicBot.IntPlayout = m / 2 + m / 35; MusicBot.TotalSendBytes = 0; resampler.ResamplerQuality = 60; int blockSize = OutFormat.AverageBytesPerSecond / 50; byte[] buffer = new byte[blockSize]; do { int byteCount; if ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0) { while (MusicBot.StopPlayingJoined) { Thread.Sleep(100); } if (byteCount < blockSize) { for (int i = byteCount; i < blockSize; ++i) { buffer[i] = (byte)0; } } MusicBot.TotalSendBytes += buffer.Length; Utils.Debug((object)("MusicBot, " + (object)MusicBot.TotalSendBytes + "/" + (object)MusicBot.IntPlayout)); if (SpecialID == MusicBot.ThreadIDD) { await MusicBot.SendVoiceData(buffer, 20, vnc); } else { goto label_31; } } else { goto label_18; } }while (MusicBot.IntPlayout > MusicBot.TotalSendBytes); Utils.Debug((object)"MusicBot, Finished playing?"); label_18: buffer = (byte[])null; } finally { if (foundationResampler != null) { foundationResampler.Dispose(); } } foundationResampler = (MediaFoundationResampler)null; } finally { if (waveStream != null) { waveStream.Dispose(); } } waveStream = (WaveStream)null; } catch (Exception ex) { Utils.Log(ex.StackTrace + "\n" + ex.Message, LogType.Error); } resampler = (MediaFoundationResampler)null; mediaStream = (WaveStream)null; OutFormat = (WaveFormat)null; goto label_33; } catch (Exception ex) { exc = ex; goto label_33; } label_31: num = 1; } catch (Exception ex) { obj = ex; } label_33: await vnc.SendSpeakingAsync(false); Exception obj1 = obj; if (obj1 != null) { Exception source = obj1 as Exception; if (source == null) { throw obj1; } ExceptionDispatchInfo.Capture(source).Throw(); } if (num == 1) { return; } obj = (Exception)null; if (exc == null) { return; } Utils.Log(string.Format("An exception occured during playback: `{0}: {1}`", (object)exc.GetType(), (object)exc.Message), LogType.Error); } }