Пример #1
0
        private void Start()
        {
            if (gateway == null)
            {
                gateway = new VoiceGateway(instance.Client);
            }

            // Initialize progress bar
            progressBar1.Maximum = (int)VoiceGateway.ConnectionState.SessionRunning;
            SetProgress(0);
            RegisterClientEvents();

            gateway.Start();
        }
Пример #2
0
        internal VoiceConnection(Channel channel, VoiceGateway voice)
        {
            _channelId = channel.Id;

            Bot          = channel.Bot;
            VoiceGateway = voice;

            VoiceGateway.OnStop += (a, b) =>
            {
                Disconnect();
            };

            if (!VoiceGateway.Running)
            {
                VoiceGateway.Start();
            }

            while (!VoiceGateway.Ready)
            {
                Thread.Sleep(200);
            }

            AudioStreamer = VoiceGateway.CreateAudioStreamer();

            AudioStreamer.OnAudioStart += (a, b) =>
            {
                OnPlayAudio?.Invoke(this, EventArgs.Empty);
            };

            AudioStreamer.OnAudioStop += (a, b) =>
            {
                OnStopAudio?.Invoke(this, EventArgs.Empty);
            };
        }