Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            lock (_syncObj)
                if (_nextInputSource != null)
                {
                    _nextInputSource.Dispose();
                    _nextInputSource = null;
                }
            PlaybackSession playbackSession = _playbackSession;

            if (playbackSession != null)
            {
                playbackSession.Dispose();
            }
        }
Ejemplo n.º 3
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();
        }