Exemple #1
0
        public async Task Add(Playlist playlist)
        {
            if (UnmanagedPlaylistContainer == null)
            {
                return;
            }
            await SpotifyObject.WaitForInitialization(UnmanagedPlaylistContainer.IsLoaded);

            UnmanagedPlaylistContainer.AddPlaylist(Link.CreateFromPlaylist(playlist));
        }
Exemple #2
0
        public override async void LoggedIn(SpotifySession session, SpotifyError error)
        {
            if (error == SpotifyError.Ok)
            {
                await SpotifyObject.WaitForInitialization(session.User().IsLoaded);

                _Session.PreferredBitrate(BitRate._320k);
            }

            _LoggedInCallback(error);
        }
Exemple #3
0
        public async Task <PlaylistCollection> GetPlaylistCollection()
        {
            var container = _Session.Playlistcontainer();

            if (container == null)
            {
                throw new SpotifyException(SpotifyError.SystemFailure, "Playlist container could not be retrieved from the library");
            }
            await SpotifyObject.WaitForInitialization(container.IsLoaded);

            return(new PlaylistCollection(container));
        }
Exemple #4
0
        public async Task Remove(Playlist playlist)
        {
            if (UnmanagedPlaylistContainer == null)
            {
                return;
            }
            await SpotifyObject.WaitForInitialization(UnmanagedPlaylistContainer.IsLoaded);

            for (int i = 0; i < UnmanagedPlaylistContainer.NumPlaylists(); i++)
            {
                var unmanagedPlaylist = UnmanagedPlaylistContainer.Playlist(i);
                await SpotifyObject.WaitForInitialization(unmanagedPlaylist.IsLoaded);

                if (unmanagedPlaylist.Name() == playlist.Name())
                {
                    UnmanagedPlaylistContainer.RemovePlaylist(i);
                    break;
                }
            }
        }
Exemple #5
0
        public async Task <IEnumerable <Playlist> > GetPlaylists()
        {
            var playlists = new List <Playlist>();

            if (UnmanagedPlaylistContainer == null)
            {
                return(playlists);
            }
            await SpotifyObject.WaitForInitialization(UnmanagedPlaylistContainer.IsLoaded);

            for (var i = 0; i < UnmanagedPlaylistContainer.NumPlaylists(); i++)
            {
                var unmanagedPlaylist = UnmanagedPlaylistContainer.Playlist(i);
                if (unmanagedPlaylist == null)
                {
                    continue;
                }
                await SpotifyObject.WaitForInitialization(unmanagedPlaylist.IsLoaded);

                playlists.Add(unmanagedPlaylist);
            }

            return(playlists);
        }