internal PlaylistContainerEventArgs(Playlist playlist, int position, int newPosition, Playlist[] currentLists)
		{
			this.playlist = playlist;
			this.position = position;
			this.newPosition = newPosition;
			this.currentLists = currentLists;
		}
Ejemplo n.º 2
0
        internal PlaylistContainer(IntPtr containerPtr, Session owningSession)
        {
            if(containerPtr == IntPtr.Zero)
                throw new ArgumentException("containerPtr can not be zero");

            lock(libspotify.Mutex)
            {
                if(containers.ContainsKey(containerPtr))
                   throw new Exception("libspotify-sharp internal error, creating playlist container for the second time");

                libspotify.sp_playlistcontainer_add_callbacks(containerPtr, callbacksPtr, IntPtr.Zero);

                this.owningSession = owningSession;
                this.containerPtr = containerPtr;
                containers.Add(containerPtr, this);

                for(int i = 0; i < PlaylistCount; i++)
                {
                    IntPtr playlistPtr = IntPtr.Zero;
                    playlistPtr = libspotify.sp_playlistcontainer_playlist(containerPtr, i);
                    Playlist p = new Playlist(playlistPtr, owningSession);
                    playlists.Add(p);
                    playlistIndexByPtr.Add(playlistPtr, i);
                }
            }
        }
Ejemplo n.º 3
0
        private static void PlaylistAddedCallback(IntPtr containerPtr, IntPtr playlistPtr, int position, IntPtr userDataPtr)
        {
            PlaylistContainer pc = GetContainer(containerPtr);

            if(pc != null)
            {
                Playlist pl;
                Playlist[] currentLists;

                lock(libspotify.Mutex)
                {
                    pl = new Playlist(playlistPtr, pc.owningSession);
                    pc.playlists.Insert(position, pl);
                    pc.playlistIndexByPtr[playlistPtr] = position;
                    currentLists = pc.CurrentLists;
                }

                pc.owningSession.EnqueueEventWorkItem(new EventWorkItem(pc.OnPlaylistAdded,
                    new object[] {pc, new PlaylistContainerEventArgs(pl, position, -1, currentLists) }));
            }
        }
Ejemplo n.º 4
0
        internal sp_error RemovePlaylist(Playlist playlist)
        {
            CheckDisposed(true);

            sp_error result = sp_error.INVALID_INDATA;

            int index = -1;
            lock(libspotify.Mutex)
            {
                if(playlistIndexByPtr.TryGetValue(playlist.playlistPtr, out index))
                {
                    if(!playlist.playlistPtr.Equals(playlists[index].playlistPtr))
                        throw new Exception("libspotify-sharp internal error, playlist position and pointer is inconsistent on remove");

                    libspotify.sp_playlistcontainer_remove_playlist(containerPtr, index);
                }
            }

            return result;
        }
Ejemplo n.º 5
0
 public static Link FromPlaylist(Playlist playlist)
 {
     ThrowHelper.ThrowIfNull(playlist, "playlist");
     return(new Link(LibSpotify.sp_link_create_from_playlist_r(playlist.Handle)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Checks whether the playlist is fully loaded. That is, if the playlist and
 /// all the containing tracks are loaded.
 /// </summary>
 /// <param name="playlist">The playlist to check</param>
 /// <returns>True if the playlist and all tracks in the playlist are loaded and the playlist does not have any pending changes. Otherwise false.</returns>
 public static bool IsFullyLoaded(this Playlist playlist)
 {
     return(playlist.IsLoaded && !playlist.HasPendingChanges && playlist.AllTracksLoaded());
 }
Ejemplo n.º 7
0
 public static bool IsFullyReady(this Playlist playlist)
 {
     return(playlist.IsLoaded && playlist.AllTracksReady());
 }