コード例 #1
0
ファイル: Music.cs プロジェクト: micmorris/NadekoBot
        internal void Cancel()
        {
            if (State == StreamTaskState.Completed)
            {
                return;
            }

            if (streamTask == null)
            {
                streamTask = new StreamTask(client, this, bufferingStream);
            }
            streamTask.CancelStreaming();
        }
コード例 #2
0
ファイル: Music.cs プロジェクト: micmorris/NadekoBot
        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();
        }