Esempio n. 1
0
        protected override void OnResetItems(IEnumerable <PlaylistItem> sourceItems, PlaylistItem item)
        {
            var copied = sourceItems.ToList();


            // 再生済みアイテムを同期
            var existPlayedItems = PlayedItem.Where(x => copied.Any(y => y.ContentId == x.ContentId));

            PlayedItem = new Stack <PlaylistItem>(existPlayedItems);

            // ランダム化したアイテムの同期
            RandamizedItems.Clear();
            var shuffledUnplayItems = copied
                                      .Where(x => !PlayedItem.Any(y => x.ContentId == y.ContentId))
                                      .Shuffle();

            foreach (var shuffled in shuffledUnplayItems)
            {
                RandamizedItems.Enqueue(shuffled);
            }

            // Currentを同期
            // 現在再生中のアイテムが削除されていた場合、Currentをnullにするだけ
            if (Current != null && !copied.Any(x => x.ContentId == Current.ContentId))
            {
                Current = null;
            }
        }
Esempio n. 2
0
        protected override PlaylistItem GetPreviousItem_Inner()
        {
            // Playedから1つ取り出して
            // Randomizedに載せる
            var prevItem = PlayedItem.Pop();

            if (Current != null && prevItem != null)
            {
                RandamizedItems.Enqueue(Current);

                return(prevItem);
            }
            else
            {
                throw new Exception();
            }
        }