示例#1
0
        internal void Cancel()
        {
            if (State == StreamTaskState.Completed)
            {
                return;
            }

            if (streamTask == null)
            {
                streamTask = new StreamTask(client, this, bufferingStream);
            }
            streamTask.CancelStreaming();
        }
示例#2
0
        internal void Start()
        {
            if (State != StreamTaskState.Queued)
            {
                return;
            }

            Stopwatch resolveTimer = Stopwatch.StartNew();

            while (resolveTimer.ElapsedMilliseconds < 8000)
            {
                if (bufferingStream != null)
                {
                    break;
                }
                Thread.Sleep(50);
            }

            if (bufferingStream == null)
            {
                Console.WriteLine("Buffering stream was not set! Can't play track!");
                streamTask = new StreamTask(client, this, null);
                streamTask.CancelStreaming();
                return;
            }

            streamTask = new StreamTask(client, this, bufferingStream);

            VoiceChannel = GetVoiceChannelForUser(User);
            if (VoiceChannel == null)
            {
                Channel.SendMessage($":warning: {User.Mention} `I can't find you in any voice channel. Join one, then try again...`");
                streamTask.CancelStreaming(); // just to set the state to done
                return;
            }

            // Go!
            streamTask.StartStreaming();
        }