Пример #1
0
        /// <summary>
        /// キューのストリームを再生開始する
        /// </summary>
        private static void PlayQueuedStream()
        {
            lock (PrepareMutex)
            {
                // 再生するstreamが用意されているかどうかチェック
                if (PreparedStream == null)
                {
                    Logger.Log("Playback Error");
                    Stop();
                    Controller._OnPlaybackErrorOccured();
                    AppCore.CoreEnqueue(() => { System.Threading.Thread.Sleep(500); Controller.NextTrack(); });
                    return;
                }

                if (PreparedStream is StopperInputStream)
                {
                    Stop();
                    return;
                }

                if (IndexInPlaylist(PreparedStream.DatabaseFileName) == -1)
                {
                    DisposePreparedStream();
                    PrepareNextStream(GetSuccTrackIndex());
                    PlayQueuedStream();
                    return;
                }

                // Output Streamを確認・再構築
                try
                {
                    EnsureOutputDevice(PreparedStream);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    Stop();
                    Controller._OnPlaybackErrorOccured();
                    AppCore.CoreEnqueue(() => { System.Threading.Thread.Sleep(500); Controller.NextTrack(); });
                    return;
                }

                DisposeCurrentStream();
                PreparedStream.Ready = true;
                CurrentStream        = PreparedStream;
                OutputDevice.Resume();
                PreparedStream = null;
                Pause          = false;
                ElapsedTime    = -1;
                Controller._OnTrackChange(Controller.Current.IndexInPlaylist);
            }
        }