示例#1
0
        public TrackReporter(IObservable <Mix> currentMixObservable, IObservable <double> currentPositionObservable, IRequestExecutor requestExecutor)
        {
            this.requestExecutor = new RequestExecutionAdapter(requestExecutor);
            IObservable <bool> reportingMarkReached = currentPositionObservable
                                                      .BufferWithCount(2, 1)
                                                      .Select(positions => (positions[0] < reportingMark && positions[1] > reportingMark));

            currentMixObservable.Subscribe(mix =>
            {
                currentMix = mix;
            });

            ReactiveAsyncCommand reportTrack = new ReactiveAsyncCommand();

            reportTrack.Subscribe(_ =>
            {
                int mixId   = currentMix.MixId;
                Track track = currentMix.GetCurrentTrack();
                Report(track, mixId);
            });

            reportingMarkReached
            .Where(x => x)                                        // we crossed the mark
            .Where(_ => !currentMix.GetCurrentTrack().IsReported) //it's not previously reported
            .Subscribe(_ => reportTrack.Execute(null));
        }
示例#2
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);
        }
示例#3
0
 public Authenticator(IRequestExecutor requestExecutor, Settings settings)
 {
     this.requestExecutor = new RequestExecutionAdapter(requestExecutor);
     this.settings        = settings;
 }
 public MediaLibraryBrowser(IRequestExecutor requestExecutor)
 {
     this.requestExecutor = new RequestExecutionAdapter(requestExecutor);
 }