internal protected Track(Session session, IntPtr trackPtr) { if (trackPtr == IntPtr.Zero) { throw new ArgumentException("trackPtr can't be zero."); } if (session == null) { throw new ArgumentNullException("Session can't be null."); } this.session = session; this.trackPtr = trackPtr; lock (libspotify.Mutex) libspotify.sp_track_add_ref(trackPtr); this.artists = new DelegateArray <IArtist>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_track_num_artists(trackPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Artist.Get(session, libspotify.sp_track_artist(trackPtr, index))); }); session.DisposeAll += new SessionEventHandler(session_DisposeAll); }
private Search(Session session, IntPtr searchPtr) { if (searchPtr == IntPtr.Zero) { throw new ArgumentException("searchPtr can't be zero"); } if (session == null) { throw new ArgumentNullException("Session can't be null"); } this.session = session; this.searchPtr = searchPtr; this.tracks = new DelegateArray <ITrack>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_tracks(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Track.Get(session, libspotify.sp_search_track(searchPtr, index))); }); this.albums = new DelegateArray <IAlbum>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_albums(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Album.Get(session, libspotify.sp_search_album(searchPtr, index))); }); this.artists = new DelegateArray <IArtist>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_artists(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Artist.Get(session, libspotify.sp_search_artist(searchPtr, index))); }); _Complete += new search_complete_cb(Search__Complete); session.DisposeAll += new SessionEventHandler(session_DisposeAll); }
private AlbumBrowse(Session session, IntPtr albumBrowsePtr) { if (albumBrowsePtr == IntPtr.Zero) { throw new ArgumentException("albumBrowsePtr can't be zero."); } if (session == null) { throw new ArgumentNullException("Session can't be null."); } this.session = session; this.albumBrowsePtr = albumBrowsePtr; this.copyrights = new DelegateArray <string>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_albumbrowse_num_copyrights(albumBrowsePtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.ImageIdToString(libspotify.sp_albumbrowse_copyright(albumBrowsePtr, index))); }); this.tracks = new DelegateArray <ITrack>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_albumbrowse_num_tracks(albumBrowsePtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Track.Get(session, libspotify.sp_albumbrowse_track(albumBrowsePtr, index))); }); _Complete += new albumbrowse_complete_cb(AlbumBrowse__Complete); session.DisposeAll += new SessionEventHandler(session_DisposeAll); }
private ArtistBrowse(Session session, IntPtr artistBrowsePtr) { if (artistBrowsePtr == IntPtr.Zero) { throw new ArgumentException("artistBrowsePtr can't be zero."); } if (session == null) { throw new ArgumentNullException("Session can't be null."); } this.session = session; this.artistBrowsePtr = artistBrowsePtr; this.portraitIds = new DelegateArray <string>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_artistbrowse_num_portraits(artistBrowsePtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.ImageIdToString(libspotify.sp_artistbrowse_portrait(artistBrowsePtr, index))); }); this.tracks = new DelegateArray <ITrack>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_artistbrowse_num_tracks(artistBrowsePtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Track.Get(session, libspotify.sp_artistbrowse_track(artistBrowsePtr, index))); }); this.albums = new DelegateArray <IAlbum>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_artistbrowse_num_albums(artistBrowsePtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Album.Get(session, libspotify.sp_artistbrowse_album(artistBrowsePtr, index))); }); this.similarArtists = new DelegateArray <IArtist>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_artistbrowse_num_similar_artists(artistBrowsePtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(SpotifyLib.Artist.Get(session, libspotify.sp_artistbrowse_similar_artist(artistBrowsePtr, index))); }); _Complete += new artistbrowse_complete_cb(ArtistBrowse__Complete); session.DisposeAll += new SessionEventHandler(session_DisposeAll); }
private Search(Session session, IntPtr searchPtr) { if (searchPtr == IntPtr.Zero) { throw new ArgumentException("searchPtr can't be zero"); } if (session == null) { throw new ArgumentNullException("Session can't be null"); } this.session = session; this.searchPtr = searchPtr; this.tracks = new DelegateArray <ITrack>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_tracks(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Track.Get(session, libspotify.sp_search_track(searchPtr, index))); }); this.albums = new DelegateArray <IAlbum>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_albums(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Album.Get(session, libspotify.sp_search_album(searchPtr, index))); }); this.artists = new DelegateArray <IArtist>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_artists(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) return(Artist.Get(session, libspotify.sp_search_artist(searchPtr, index))); }); this.playlists = new DelegateArray <IPlaylist>(() => { IsAlive(true); lock (libspotify.Mutex) return(libspotify.sp_search_num_playlists(searchPtr)); }, (index) => { IsAlive(true); lock (libspotify.Mutex) { string playlistUri = libspotify.sp_search_playlist_uri(searchPtr, index); var playlistLink = session.ParseLink(playlistUri); if (playlistLink.Type == sp_linktype.SP_LINKTYPE_PLAYLIST) { var playlist = playlistLink.As <IPlaylist>(); playlistLink.Dispose(); return(playlist); } else { throw new Exception("Wrong link type: " + playlistLink.Type.ToString()); } } }); _Complete += new search_complete_cb(Search__Complete); session.DisposeAll += new SessionEventHandler(session_DisposeAll); }