Пример #1
0
        private AudioTrack getNextPlaylistTrack()
        {
            AudioTrack track = null;

            using (var db = new Podcatcher.PlaylistDBContext())
            {
                if (db.Playlist.Count() <= 1)
                {
                    // Only current item in the playlist. Cannot progress to next one.
                    return(null);
                }

                int orderNumber = db.Playlist.Where(item => item.IsCurrent).Select(item => item.OrderNumber).FirstOrDefault();
                Podcatcher.ViewModels.PlaylistItem currentTrack = db.Playlist.Where(item => item.IsCurrent).FirstOrDefault();

                if (currentTrack != null)
                {
                    currentTrack.IsCurrent = false;
                }

                Podcatcher.ViewModels.PlaylistItem nextTrack = db.Playlist.Where(item => item.OrderNumber == orderNumber + 1).FirstOrDefault();
                if (nextTrack == null)
                {
                    db.SubmitChanges();
                    return(null);
                }

                track = new AudioTrack(new Uri(nextTrack.EpisodeLocation, UriKind.RelativeOrAbsolute),
                                       nextTrack.EpisodeName,
                                       nextTrack.PodcastName,
                                       "",
                                       new Uri(nextTrack.PodcastLogoLocation, UriKind.RelativeOrAbsolute));

                nextTrack.IsCurrent = true;
                db.SubmitChanges();
            }

            return(track);
        }
Пример #2
0
 private void removeFromPlayqueue(PlaylistItem plItem)
 {
     removeFromPlayqueue(plItem.ItemId);
 }
Пример #3
0
 public PodcastEpisodeModel episodeForPlaylistItem(PlaylistItem item)
 {
     return Episodes.FirstOrDefault(ep => ep.EpisodeId == item.ItemId);
 }
Пример #4
0
 public void play(PlaylistItem playlistItem)
 {
     using (PodcastSqlModel db = new PodcastSqlModel()) {
         PodcastEpisodeModel episode = db.Episodes.FirstOrDefault(ep => ep.EpisodeId == playlistItem.EpisodeId);
         if (episode != null)
         {
             play(episode);
         }
     }
 }
Пример #5
0
        private void updateToDBPlaylistItem(PlaylistItem pl)
        {
            using (var db = new Podcatcher.PlaylistDBContext())
            {
                PlaylistItem p = db.Playlist.FirstOrDefault(item => item.ItemId == pl.ItemId);
                if (p == null) {
                    Debug.WriteLine("Something went horribly wrong. Cannot update playlist item to DB.");
                    return;
                }

                p.IsCurrent = pl.IsCurrent;
                p.EpisodeName = pl.EpisodeName;
                p.EpisodeLocation = pl.EpisodeLocation;
                p.OrderNumber = pl.OrderNumber;
                p.SavedPlayPosTick = pl.SavedPlayPosTick;
                p.TotalPlayTicks = pl.TotalPlayTicks;

                db.SubmitChanges();
            }
        }