Пример #1
0
        //private readonly Random _random = new Random((int)DateTime.Now.Ticks);

        #endregion

        #region ctor

        public PlaybackQueue(
            IAudioPlaybackEngineSync audioPlayer
            //, IObservable<IChangeSet<Track> tracksCacheChanges
            )
        {
            this._audioPlayer = audioPlayer ?? throw new ArgumentNullException(nameof(audioPlayer));

            this._isShuffleActivated_BehaviorSubject = new BehaviorSubject <bool>(false).DisposeWith(this._disposables);
            this._sourcedEntries = new SourceList <PlaybackQueueEntry>().DisposeWith(this._disposables);

            Observable.CombineLatest(
                this._audioPlayer.WhenCanLoadChanged,
                this._audioPlayer.WhenCanPlayChanged,
                (canLoad, canPlay) => canLoad && !canPlay)
            .Where(canLoadButNotPlay => canLoadButNotPlay == true)
            .Subscribe((s) =>
            {
                PlaybackQueueEntry next = null;     // = this._playlistEntries.Items.FirstOrDefault();

                this._playlistEntries.Edit(list =>
                {
                    next = list.FirstOrDefault();
                    if (next == null)
                    {
                        // unsubscribe from playlist?
                        return;
                    }
                    list.RemoveAt(0);
                });

                if (next == null)
                {
                    return;
                }

                switch (next.Track)
                {
                case Track nextTrack:
                    this._audioPlayer.LoadAndPlay(nextTrack);
                    break;
                }
            })
            .DisposeWith(this._disposables);

            //this._upNextEntries = new SourceList<PlaybackQueueEntry>().DisposeWith(this._disposables);
            this._playlistEntries = new SourceList <PlaybackQueueEntry>().DisposeWith(this._disposables);

            //this._upNextEntries.Connect().Bind(out this._upNextEntriesROOC);
            this._playlistEntries.Connect().Bind(out this._playlistEntriesROOC);
        }
Пример #2
0
 public void RemoveFromSourcedQueue(PlaybackQueueEntry queueEntry)
 {
 }