public async Task <AlbumBrowse> FetchAlbum(string linkStr)
        {
            var link  = Link.CreateFromString(linkStr);
            var album = AlbumBrowse.Create(_session, link.AsAlbum(), AlbumBrowseCallBack, _session.UserData);

            await WaitForBool(album.IsLoaded);

            for (int i = 0; i < album.NumTracks(); i++)
            {
                await WaitForBool(album.Track(i).IsLoaded);
            }
            return(album);
        }
Пример #2
0
        public int CmdBrowse(string[] args)
        {
            if (args.Length != 2)
            {
                Console.Error.WriteLine("Usage: browse <spotify-url>");
                return(-1);
            }
            var link = Link.CreateFromString(args[1]);

            if (link == null)
            {
                Console.Error.WriteLine("Not a spotify link");
                return(-1);
            }
            switch (link.Type())
            {
            default:
                Console.Error.WriteLine("Can not handle link");
                link.Release();
                return(-1);

            case LinkType.Album:
                AlbumBrowse.Create(iSession, link.AsAlbum(), BrowseAlbumCallback, null);
                break;

            case LinkType.Artist:
                ArtistBrowse.Create(iSession, link.AsArtist(), ArtistBrowseType.Full, BrowseArtistCallback, null);
                break;

            case LinkType.Localtrack:
            case LinkType.Track:
                iTrackBrowse = link.AsTrack();
                iMetadataWaiter.AddMetadataUpdatedCallback(TrackBrowseTry);
                iTrackBrowse.AddRef();
                TrackBrowseTry();
                break;

            case LinkType.Playlist:
                BrowsePlaylist(Playlist.Create(iSession, link));
                break;
            }
            link.Release();
            return(0);
        }