Beispiel #1
0
 private async Task<List<Track>> BuildTracks(Album album)
 {
     var list = new List<Track>();
     using (dynamic client = this.CreateDynamicClient(album.Key))
     {
         dynamic result = await client.get();
         var tracks = result._children as IEnumerable<dynamic>;
         foreach (dynamic track in tracks)
         {
             var t = new Track(album, track);
             if (t.Duration > 0)
                 list.Add(t);
         }
     }
     return list;
 }
 private static mediaCollection BuildAlbum(Album p)
 {
     return new mediaCollection() { id = String.Format("Alb/{0}", p.Key), itemType = itemType.album, canEnumerate = true, canEnumerateSpecified = true, canPlay = true, canPlaySpecified = true, title = p.Name, summary = p.Summary, artist = p.Parent.Name, albumArtURI = (!String.IsNullOrEmpty(p.ThumbLocation) ? new albumArtUrl() { Value = String.Format("http://192.168.1.227:8888/ImageService/GetImage?image={0}", p.ThumbLocation) } : null) };
 }
Beispiel #3
0
        private async Task<List<Album>> GetArtistAlbums(Artist artist)
        {
            var list = new List<Album>();
            using (dynamic client = this.CreateDynamicClient(artist.Key))
            {
                dynamic result = await client.get();
                var albums = result._children as IEnumerable<dynamic>;
                var tasks = albums.Select(async album =>
                {
                    var a = new Album(artist, album);
                    a.Tracks = await BuildTracks(a);
                    if (a.Tracks.Count > 0)
                    {
                        lock (list) //ick, yes need to do concurrent
                        {
                            list.Add(a);
                        }
                    }
                });
                await Task.WhenAll(tasks);
                return list;

            }
        }