Beispiel #1
0
 public void Pause()
 {
     if (_internalState == InternalPlaybackState.Playing)
     {
         _controller.OutputDeviceManager.StopDevice(false);
         _internalState = InternalPlaybackState.Paused;
     }
 }
Beispiel #2
0
 public void Resume()
 {
     if (_internalState == InternalPlaybackState.Paused)
     {
         _controller.OutputDeviceManager.StartDevice();
         _internalState = InternalPlaybackState.Playing;
     }
 }
Beispiel #3
0
        public void Stop()
        {
            if (_internalState == InternalPlaybackState.Playing || _internalState == InternalPlaybackState.Paused)
            {
                PlaybackSession session = _playbackSession;
                _playbackSession = null;
                if (session != null)
                {
                    session.End(false);
                    session.Dispose();
                }

                _internalState = InternalPlaybackState.Stopped;
            }
        }
Beispiel #4
0
 protected void Initialize()
 {
     _internalState = InternalPlaybackState.Stopped;
 }
Beispiel #5
0
        /// <summary>
        /// Moves to the next available input source.
        /// </summary>
        /// <remarks>
        /// This method blocks the calling thread as long as the switching to the new input source lasts. This includes
        /// the crossfading duration (if crossfading is done) or the fading out (if no crossfading is done).
        /// </remarks>
        protected void MoveToNextInputSource_Sync()
        {
            // TODO: Insert gap between tracks if we are in playback mode Normal
            IInputSource inputSource = PeekNextInputSource();

            if (_playbackSession != null)
            {
                BassCDTrackInputSource bcdtisNew          = inputSource as BassCDTrackInputSource;
                IInputSource           currentInputSource = _playbackSession.CurrentInputSource;
                BassCDTrackInputSource bcdtisOld          = currentInputSource as BassCDTrackInputSource;
                if (bcdtisOld != null && bcdtisNew != null)
                {
                    // Special treatment for CD drives: If the new input source is from the same audio CD drive, we must take the stream over
                    if (bcdtisOld.SwitchTo(bcdtisNew))
                    {
                        _playbackSession.IsAwaitingNextInputSource = false;
                        ClearNextInputSource();
                        return;
                    }
                }
                // TODO: Trigger crossfading if CF is configured
                _playbackSession.End(_internalState == InternalPlaybackState.Playing); // Only wait for fade out when we are playing
            }

            _internalState = InternalPlaybackState.Playing;
            if (inputSource == null)
            {
                Log.Debug("No more input sources available.");
            }
            else
            {
                Log.Debug("Playing next input source '{0}'", inputSource);
            }
            if (_playbackSession != null)
            {
                if (_playbackSession.InitializeWithNewInputSource(inputSource))
                {
                    _playbackSession.Play();
                    ClearNextInputSource();
                    return;
                }
                _playbackSession.Dispose();
                _playbackSession = null;
            }

            if (inputSource == null)
            {
                Ended();
                return;
            }

            _playbackSession = PlaybackSession.Create(_controller);
            if (_playbackSession == null)
            {
                _internalState = InternalPlaybackState.Stopped;
                return;
            }
            _playbackSession.Play();

            _internalState = InternalPlaybackState.Playing;
            _controller.StateReady();
        }
 protected void Ended()
 {
   _internalState = InternalPlaybackState.Stopped;
   _controller.PlaybackEnded_Async();
 }
Beispiel #7
0
 protected void Ended()
 {
     _internalState = InternalPlaybackState.Stopped;
     _controller.PlaybackEnded_Async();
 }
 protected void Initialize()
 {
   _internalState = InternalPlaybackState.Stopped;
 }
 public void Resume()
 {
   if (_internalState == InternalPlaybackState.Paused)
   {
     _controller.OutputDeviceManager.StartDevice();
     _internalState = InternalPlaybackState.Playing;
   }
 }
 public void Pause()
 {
   if (_internalState == InternalPlaybackState.Playing)
   {
     _controller.OutputDeviceManager.StopDevice(false);
     _internalState = InternalPlaybackState.Paused;
   }
 }
    public void Stop()
    {
      if (_internalState == InternalPlaybackState.Playing || _internalState == InternalPlaybackState.Paused)
      {
        PlaybackSession session = _playbackSession;
        _playbackSession = null;
        if (session != null)
        {
          session.End(false);
          session.Dispose();
        }

        _internalState = InternalPlaybackState.Stopped;
      }
    }
    /// <summary>
    /// Moves to the next available input source.
    /// </summary>
    /// <remarks>
    /// This method blocks the calling thread as long as the switching to the new input source lasts. This includes
    /// the crossfading duration (if crossfading is done) or the fading out (if no crossfading is done).
    /// </remarks>
    protected void MoveToNextInputSource_Sync()
    {
      // TODO: Insert gap between tracks if we are in playback mode Normal
      IInputSource inputSource = PeekNextInputSource();

      if (_playbackSession != null)
      {
        BassCDTrackInputSource bcdtisNew = inputSource as BassCDTrackInputSource;
        IInputSource currentInputSource = _playbackSession.CurrentInputSource;
        BassCDTrackInputSource bcdtisOld = currentInputSource as BassCDTrackInputSource;
        if (bcdtisOld != null && bcdtisNew != null)
        {
          // Special treatment for CD drives: If the new input source is from the same audio CD drive, we must take the stream over
          if (bcdtisOld.SwitchTo(bcdtisNew))
          {
            _playbackSession.IsAwaitingNextInputSource = false;
            ClearNextInputSource();
            return;
          }
        }
        // TODO: Trigger crossfading if CF is configured
        _playbackSession.End(_internalState == InternalPlaybackState.Playing); // Only wait for fade out when we are playing
      }

      _internalState = InternalPlaybackState.Playing;
      if (inputSource == null)
        Log.Debug("No more input sources available.");
      else
        Log.Debug("Playing next input source '{0}'", inputSource);
      if (_playbackSession != null)
      {
        if (_playbackSession.InitializeWithNewInputSource(inputSource))
        {
          _playbackSession.Play();
          ClearNextInputSource();
          return;
        }
        _playbackSession.Dispose();
        _playbackSession = null;
      }

      if (inputSource == null)
      {
        Ended();
        return;
      }

      _playbackSession = PlaybackSession.Create(_controller);
      if (_playbackSession == null)
      {
        _internalState = InternalPlaybackState.Stopped;
        return;
      }
      _playbackSession.Play();

      _internalState = InternalPlaybackState.Playing;
      _controller.StateReady();
    }