コード例 #1
0
		internal AlbumBrowse(IntPtr albumBrowsePtr)
		{
			if(albumBrowsePtr == IntPtr.Zero)
				throw new ArgumentException("albumBrowsePtr can not be zero");
			
			lock(libspotify.Mutex)
			{
				IntPtr strPtr = IntPtr.Zero;
				
				error = libspotify.sp_albumbrowse_error(albumBrowsePtr);
				album = new Album(libspotify.sp_albumbrowse_album(albumBrowsePtr));
				artist = new Artist(libspotify.sp_albumbrowse_artist(albumBrowsePtr));
				
				copyrights = new string[libspotify.sp_albumbrowse_num_copyrights(albumBrowsePtr)];
				for(int i = 0; i < copyrights.Length; i++)
				{
					strPtr = libspotify.sp_albumbrowse_copyright(albumBrowsePtr, i);
					copyrights[i] = libspotify.GetString(strPtr, string.Empty);
				}
				
				tracks = new Track[libspotify.sp_albumbrowse_num_tracks(albumBrowsePtr)];
				for(int i = 0; i < tracks.Length; i++)
				{
					IntPtr trackPtr = libspotify.sp_albumbrowse_track(albumBrowsePtr, i);
					tracks[i] = new Track(trackPtr);
				}
				
				strPtr = libspotify.sp_albumbrowse_review(albumBrowsePtr);
                review = libspotify.GetString(strPtr, string.Empty);
				
				libspotify.sp_albumbrowse_release(albumBrowsePtr);
			}
		}
コード例 #2
0
ファイル: Artist.cs プロジェクト: nmghr9/libspotify-sharp
		public static string ArtistsToString(Artist[] artists)
		{
			if(artists == null)
				return string.Empty;
			
			List<string> names = new List<string>();
			foreach(Artist a in artists)
				names.Add(a.Name);
			
			return string.Join(", ", names.ToArray());
		}
コード例 #3
0
        internal ArtistBrowse(IntPtr artistBrowsePtr)
        {
            if(artistBrowsePtr == IntPtr.Zero)
                throw new ArgumentException("artistBrowsePtr can not be zero");

            lock(libspotify.Mutex)
            {
                IntPtr strPtr = IntPtr.Zero;

                error = libspotify.sp_artistbrowse_error(artistBrowsePtr);
                artist = new Artist(libspotify.sp_artistbrowse_artist(artistBrowsePtr));

                portraitIds = new List<string>(libspotify.sp_artistbrowse_num_portraits(artistBrowsePtr));
                for(int i = 0; i < portraitIds.Count; i++)
                {
                    IntPtr portraitIdPtr = libspotify.sp_artistbrowse_portrait(artistBrowsePtr, i);
                    byte[] portraitId = new byte[20];
                    Marshal.Copy(portraitIdPtr, portraitId, 0, portraitId.Length);
                    portraitIds.Add(libspotify.ImageIdToString(portraitId));
                }

                tracks = new Track[libspotify.sp_artistbrowse_num_tracks(artistBrowsePtr)];
                for(int i = 0; i < tracks.Length; i++)
                {
                    IntPtr trackPtr = libspotify.sp_artistbrowse_track(artistBrowsePtr, i);
                    tracks[i] = new Track(trackPtr);
                }

                albums = new Album[libspotify.sp_artistbrowse_num_albums(artistBrowsePtr)];
                for(int i = 0; i < albums.Length; i++)
                {
                    IntPtr albumPtr = libspotify.sp_artistbrowse_album(artistBrowsePtr, i);
                    albums[i] = new Album(albumPtr);
                }

                similarArtists = new Artist[libspotify.sp_artistbrowse_num_similar_artists(artistBrowsePtr)];
                for(int i = 0; i < similarArtists.Length; i++)
                {
                    IntPtr artistPtr = libspotify.sp_artistbrowse_similar_artist(artistBrowsePtr, i);
                    similarArtists[i] = new Artist(artistPtr);
                }

                strPtr = libspotify.sp_albumbrowse_review(artistBrowsePtr);
                biography = libspotify.GetString(strPtr, string.Empty);

                libspotify.sp_artistbrowse_release(artistBrowsePtr);
            }
        }
コード例 #4
0
ファイル: Artist.cs プロジェクト: nmghr9/libspotify-sharp
		public static Artist CreateFromLink(Link link)
		{
			Artist result = null;
			
			if(link.linkPtr != IntPtr.Zero)
			{
				lock(libspotify.Mutex)
				{
					IntPtr artistPtr = libspotify.sp_link_as_artist(link.linkPtr);
					if(artistPtr != IntPtr.Zero)
						result = new Artist(artistPtr);
				}
			}
			
			return result;
		}
コード例 #5
0
ファイル: Search.cs プロジェクト: nmghr9/libspotify-sharp
        internal Search(IntPtr searchPtr)
        {
            if (searchPtr == IntPtr.Zero)
                throw new ArgumentException("searchPtr can not be zero");

			this.searchPtr = searchPtr;
			
            lock (libspotify.Mutex)
            {
                IntPtr strPtr = IntPtr.Zero;

                error = libspotify.sp_search_error(searchPtr);

                tracks = new Track[libspotify.sp_search_num_tracks(searchPtr)];
                for (int i = 0; i < tracks.Length; i++)
                {
                    IntPtr trackPtr = libspotify.sp_search_track(searchPtr, i);
                    tracks[i] = new Track(trackPtr);
                }

                albums = new Album[libspotify.sp_search_num_albums(searchPtr)];
                for (int i = 0; i < albums.Length; i++)
                {
                    IntPtr albumPtr = libspotify.sp_search_album(searchPtr, i);
                    albums[i] = new Album(albumPtr);
                }

                artists = new Artist[libspotify.sp_search_num_artists(searchPtr)];
                for (int i = 0; i < artists.Length; i++)
                {
                    IntPtr artistPtr = libspotify.sp_search_artist(searchPtr, i);
                    artists[i] = new Artist(artistPtr);
                }

                strPtr = libspotify.sp_search_query(searchPtr);
                query = libspotify.GetString(strPtr, string.Empty);

                strPtr = libspotify.sp_search_did_you_mean(searchPtr);
                didYouMean = libspotify.GetString(strPtr, string.Empty);

                totalTracks = libspotify.sp_search_total_tracks(searchPtr);                
            }
        }
コード例 #6
0
ファイル: Session.cs プロジェクト: stever/spotify-resolver
        internal ArtistBrowse BrowseArtistSync(Artist artist, TimeSpan timeout)
        {
            ManualResetEvent waitHandle = new ManualResetEvent(false);
            int id = GetInternalStateId();

            lock(libspotify.Mutex)
            {
                states[id] = waitHandle;
                if(libspotify.sp_artistbrowse_create(sessionPtr, artist.artistPtr,
                    Marshal.GetFunctionPointerForDelegate(artistbrowse_complete_cb), new IntPtr(id)) == IntPtr.Zero)
                {
                    waitHandle.Close();
                    states.Remove(id);
                    return null;
                }
            }

            return GetSyncResponse(id, waitHandle, timeout) as ArtistBrowse;
        }
コード例 #7
0
ファイル: Session.cs プロジェクト: stever/spotify-resolver
 internal bool BrowseArtist(Artist artist, object state)
 {
     lock(libspotify.Mutex)
     {
         int id = GetUserStateId();
         states[id] = state;
         IntPtr browsePtr = libspotify.sp_artistbrowse_create(sessionPtr, artist.artistPtr,
             Marshal.GetFunctionPointerForDelegate(artistbrowse_complete_cb), new IntPtr(id));
         return browsePtr != IntPtr.Zero;
     }
 }
コード例 #8
0
ファイル: Track.cs プロジェクト: krikelin/MediaChrome
        internal void CheckLoaded()
        {
            CheckDisposed(true);

            if(isLoaded)
                return;

            lock(libspotify.Mutex)
                isLoaded = libspotify.sp_track_is_loaded(trackPtr);

            if(!isLoaded)
                return;

            lock(libspotify.Mutex)
            {
                isAvailable = libspotify.sp_track_is_available(trackPtr);

                error = libspotify.sp_track_error(trackPtr);
                IntPtr albumPtr = libspotify.sp_track_album(trackPtr);
                if (albumPtr != IntPtr.Zero)
                    album = new Album(albumPtr);

                artists = new Artist[libspotify.sp_track_num_artists(trackPtr)];
                for(int i = 0; i < artists.Length; i++)
                    artists[i] = new Artist(libspotify.sp_track_artist(trackPtr, i));

                name = libspotify.GetString(libspotify.sp_track_name(trackPtr), string.Empty);

                duration = libspotify.sp_track_duration(trackPtr);
                popularity = libspotify.sp_track_popularity(trackPtr);
                disc = libspotify.sp_track_disc(trackPtr);
                index = libspotify.sp_track_index(trackPtr);

                using(Link l = CreateLink(0))
                {
                    linkString = l.ToString();
                }
            }
        }
コード例 #9
0
ファイル: Link.cs プロジェクト: gladish/Spotify.NET
 public static Link FromArtistPortrait(Artist artist, ImageSize size)
 {
     ThrowHelper.ThrowIfNull(artist, "artist");
     return(new Link(LibSpotify.sp_link_create_from_artist_portrait_r(artist.Handle, size)));
 }
コード例 #10
0
ファイル: Link.cs プロジェクト: gladish/Spotify.NET
 public static Link FromArtist(Artist artist)
 {
     ThrowHelper.ThrowIfNull(artist, "artist");
     return(new Link(LibSpotify.sp_link_create_from_artist_r(artist.Handle)));
 }