Example #1
0
        public Spotify()
        {
            _session = new Session();
            d_notify = new Action<IntPtr>(Session_OnNotifyMainThread);
            d_on_logged_in = new Action<IntPtr>(Session_OnLoggedIn);

            Initialize();
        }
Example #2
0
        public Artist(IntPtr artistPtr, Session session)
        {
            _session = session;

            if (artistPtr == IntPtr.Zero)
                throw new InvalidOperationException("Artist pointer is null.");

            this.ArtistPtr = artistPtr;
            this.Name = Functions.PtrToString(libspotify.sp_artist_name(artistPtr));
        }
Example #3
0
        public TopList(libspotify.sp_toplisttype type, int region, Session session)
        {
            _session = session;
            try {
                ToplistType = type;
                toplistbrowse_complete_cb_delegate d = new toplistbrowse_complete_cb_delegate(toplistbrowse_complete);
                IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(d);

                _browsePtr = libspotify.sp_toplistbrowse_create(_session.GetSessionPtr(), type, region, IntPtr.Zero, callbackPtr, IntPtr.Zero);
            } catch (Exception ex) {
                throw ex;
            }
        }
Example #4
0
        public Album(IntPtr albumPtr, Session session)
        {
            _session = session;
            if (albumPtr == IntPtr.Zero)
                throw new InvalidOperationException("Album pointer is null.");

            this.AlbumPtr = albumPtr;
            this.Name = Functions.PtrToString(libspotify.sp_album_name(albumPtr));
            this.Type = libspotify.sp_album_type(albumPtr);
            IntPtr artistPtr = libspotify.sp_album_artist(albumPtr);
            if(artistPtr != IntPtr.Zero)
                this.Artist = Functions.PtrToString(libspotify.sp_artist_name(artistPtr));
        }
Example #5
0
        private Playlist(IntPtr playlistPtr, Session session)
        {
            _session = session;
            this.Pointer = playlistPtr;

            initCallbacks();

            if (this.IsLoaded) {

                populateMetadata();
                return;

            }
        }
Example #6
0
        public Track(IntPtr trackPtr, Session session)
        {
            _session = session;

            if (!libspotify.sp_track_is_loaded(trackPtr))
                throw new InvalidOperationException("Track is not loaded.");

            this.TrackPtr = trackPtr;
            this.Name = Functions.PtrToString(libspotify.sp_track_name(trackPtr));
            this.TrackNumber = libspotify.sp_track_index(trackPtr);
            this.Seconds = (decimal)libspotify.sp_track_duration(trackPtr) / 1000M;
            IntPtr albumPtr = libspotify.sp_track_album(trackPtr);
            if(albumPtr != IntPtr.Zero)
                this.Album = new Album(albumPtr, _session);

            for (int i = 0; i < libspotify.sp_track_num_artists(trackPtr); i++) {

                IntPtr artistPtr = libspotify.sp_track_artist(trackPtr, i);
                if(artistPtr != IntPtr.Zero)
                    _artists.Add(Functions.PtrToString(libspotify.sp_artist_name(artistPtr)));

            }
        }
 public PlaylistContainer(IntPtr containerPtr, Session session)
 {
     _session = session;
     _containerPtr = containerPtr;
     initCallbacks();
 }
Example #8
0
 public static Playlist Get(IntPtr playlistPtr, Session session)
 {
     Playlist p = new Playlist((IntPtr)playlistPtr, session);
     return p;
 }