示例#1
0
        public PlaybackController(IAudioPlayer audioPlayer, IRequestExecutor requestExecutor)
        {
            this.audioPlayerProxy = new StatefullAudioPlayer(audioPlayer);
            this.requestExecutor  = new RequestExecutionAdapter(requestExecutor);

            audioPlayerProxy.EndOfStreamReached +=
                new EventHandler <EndOfStreamReachedEventArgs>(audioPlayerProxy_EndOfStreamReached);

            //bring the position to zero if we reach the end of stream
            audioPlayerProxy.CurrentPositionObservable
            .Where(_ => audioPlayerProxy.Status == MediaStatus.Running)
            .Where(currentPosition => currentPosition == audioPlayerProxy.CurrentTrackDuration)
            .Subscribe(_ => audioPlayerProxy.SkipTo(0));


            audioPlayerProxy.CurrentPositionObservable
            .Where(_ => audioPlayerProxy.Status == MediaStatus.Running)
            .Select(_ => audioPlayerProxy.CurrentTrackDuration)
            .Where(duration => duration > 0)
            .DistinctUntilChanged()
            .Subscribe(duration =>
            {
                currentDurationObservable.OnNext(duration);
                currentMix.GetCurrentTrack().Duration = audioPlayerProxy.CurrentTrackDuration;
            });

            currentMixObservable.OnNext(Mix.NoMixAvailable);
        }
示例#2
0
 public void SkipTo(double positionInSeconds)
 {
     audioPlayerProxy.SkipTo((int)positionInSeconds);
 }
示例#3
0
 private void TheApplicationIssuesACommandToSkipTo_Second(int newPosition)
 {
     statefullAudioPlayer.SkipTo(newPosition);
 }