Пример #1
0
        internal int AddPlayQueueEntry(PlayQueueEntryTable newPlayQueueEntry)
        {
            sqlConnection.Insert(newPlayQueueEntry);

            return newPlayQueueEntry.RowId;
        }
Пример #2
0
        internal int AddPlayQueueEntry(PlayQueueEntryTable newPlayQueueEntry)
        {
            sqlConnection.Insert(newPlayQueueEntry);

            return(newPlayQueueEntry.RowId);
        }
Пример #3
0
        private int AddSong(int songId)
        {
            // Keep queue trimmed
            if (LookupMap.Count >= MAX_QUEUE_SIZE)
            {
                PlayQueueEntryModel head = null;

                if (PlaybackQueue.Count > 0)
                {
                    head = PlaybackQueue.First();
                }

                if (head != null)
                {
                    if (CurrentPlaybackQueueEntryId == head.RowId)
                    {
                        // TODO: #6 raise alert about queue being full
                        return -1;
                    }
                    else
                    {
                        RemoveEntry(head.RowId);
                    }
                }
            }

            PlayQueueEntryModel currentTail = null;

            if (PlaybackQueue.Count > 0)
            {
                currentTail = PlaybackQueue.Last();
            }

            PlayQueueEntryTable newPlayQueueEntry;

            if (currentTail == null)
            {
                newPlayQueueEntry = new PlayQueueEntryTable(songId, 0, 0);

                DatabaseManager.Current.AddPlayQueueEntry(newPlayQueueEntry);
            }
            else
            {
                newPlayQueueEntry = new PlayQueueEntryTable(songId, 0, currentTail.RowId);
               
                DatabaseManager.Current.AddPlayQueueEntry(newPlayQueueEntry);

                currentTail.NextId = newPlayQueueEntry.RowId;
            }

            PlayQueueEntryModel newEntry = new PlayQueueEntryModel(newPlayQueueEntry);

            LookupMap.Add(newEntry.RowId, newEntry);
            PlaybackQueue.Add(newEntry);

            NotifyPropertyChanged(Properties.NextTrack);
            NotifyPropertyChanged(Properties.PrevTrack);

            return newEntry.RowId;
        }