MediaPortal.MusicPlayer.BASS.BassAudioEngine.Pause C# (CSharp) 메소드

Pause() 공개 메소드

Pause Playback
public Pause ( ) : void
리턴 void
    public override void Pause()
    {
      MusicStream stream = GetCurrentStream();

      try
      {
        PlayState oldPlayState = _state;

        if (oldPlayState == PlayState.Ended || oldPlayState == PlayState.Init)
        {
          return;
        }

        if (oldPlayState == PlayState.Paused)
        {
          // The connection of a Webstream may have timed out, during Pause.
          // The only way to resolve this is to Stop the Stream and restart it
          if (stream.Filetype.FileMainType == FileMainType.WebStream && !g_Player.ForcePauseWebStream) // in case of UPnP Renderer we want support pause
          {
            _state = PlayState.Ended;
            var filePath = stream.FilePath;
            Log.Debug("BASS: Stopping and Restarting Webstream {0}", stream.FilePath);
            g_Player.OnStopped();
            Stop();
            Play(filePath);
            return;
          }

          Log.Debug("BASS: Resuming stream {0}", stream.FilePath);
          _state = PlayState.Playing;

          if (Config.SoftStop)
          {
            // Fade-in over 500ms
            Bass.BASS_ChannelSlideAttribute(_mixer.BassStream, BASSAttribute.BASS_ATTRIB_VOL, 1, 500);
          }
          else
          {
            Bass.BASS_ChannelSetAttribute(_mixer.BassStream, BASSAttribute.BASS_ATTRIB_VOL, 1);
          }

          BassMix.BASS_Mixer_ChannelPlay(_mixer.BassStream);
          Bass.BASS_Start();

          if (Config.MusicPlayer == AudioPlayer.Asio)
          {
            BassAsio.BASS_ASIO_ChannelReset(false, 0, BASSASIOReset.BASS_ASIO_RESET_PAUSE);
          }
          else if (Config.MusicPlayer == AudioPlayer.WasApi)
          {
            BassWasapi.BASS_WASAPI_Start();
          }
        }

        else
        {
          Log.Debug("BASS: Pausing stream {0}", stream.FilePath);
          _state = PlayState.Paused;

          if (Config.SoftStop)
          {
            // Fade-out over 500ms
            Bass.BASS_ChannelSlideAttribute(_mixer.BassStream, BASSAttribute.BASS_ATTRIB_VOL, 0, 500);

            // Wait until the slide is done
            while (Bass.BASS_ChannelIsSliding(_mixer.BassStream, BASSAttribute.BASS_ATTRIB_VOL))
              System.Threading.Thread.Sleep(20);
          }

          BassMix.BASS_Mixer_ChannelPause(_mixer.BassStream);
          Bass.BASS_Pause();

          if (Config.MusicPlayer == AudioPlayer.Asio)
          {
            BassAsio.BASS_ASIO_ChannelPause(false, 0);
          }
          else if (Config.MusicPlayer == AudioPlayer.WasApi)
          {
            BassWasapi.BASS_WASAPI_Stop(true);
          }
        }

        if (oldPlayState != _state)
        {
          if (PlaybackStateChanged != null)
          {
            PlaybackStateChanged(this, oldPlayState, _state);
          }
        }
      }

      catch { }
    }