Example #1
0
        // Obtain the current details of the Spotify player, both track info and the player status
        private MediaPlayerDetails getCurrentSpotifyDetails()
        {
            MediaPlayerDetails retVal = new MediaPlayerDetails();

            Responses.Status Current_Status = m_spotifyApiInstance.Status;
            if (m_cfid.error != null)
            {
                Console.WriteLine(string.Format("Spotify returned a error {0} (0x{1})", m_cfid.error.message, m_cfid.error.type));
                Thread.Sleep(-1);
            }

            if (Current_Status.track != null)
            {
                retVal.currentTrack  = Current_Status.track.track_resource.name;
                retVal.currentAlbum  = Current_Status.track.album_resource.name;
                retVal.currentArtist = Current_Status.track.artist_resource.name;
                int pos = (int)Current_Status.playing_position;
                int len = Current_Status.track.length;
                retVal.playTime = String.Format("{0}:{1:D2}/{2}:{3:D2}", pos / 60, pos % 60, len / 60, len % 60);
            }

            retVal.playing        = Current_Status.playing;
            retVal.online         = Current_Status.online;
            retVal.privateSession = Current_Status.open_graph_state.private_session;

            return(retVal);
        }
Example #2
0
        // Obtain the current details of the Spotify player, both track info and the player status
        private MediaPlayerDetails getCurrentSpotifyDetails()
        {
            MediaPlayerDetails retVal = new MediaPlayerDetails();
            //Responses.Status current_Status = m_spotifyApiInstance.Status;
            StatusResponse current_Status = s_spotify.GetStatus();

            if (current_Status.Track == null)
            {
                ;
            }
            else if (current_Status.Track.IsAd())
            {
                ;
            }
            else
            {
                Debug.Print("Track Information:");
                Debug.Print("\tTrack: " + current_Status.Track.TrackResource.Name);
                Debug.Print("\tArtist: " + current_Status.Track.ArtistResource.Name);
                Debug.Print("\tAlbum: " + current_Status.Track.AlbumResource.Name);
                Debug.Print("\tPlaying Position (Seconds): " + current_Status.PlayingPosition);
                Debug.Print("\tPlay Time Total (Seconds): " + current_Status.Track.Length);
                retVal.currentTrack  = current_Status.Track.TrackResource.Name;
                retVal.currentAlbum  = current_Status.Track.AlbumResource.Name;
                retVal.currentArtist = current_Status.Track.ArtistResource.Name;
                int pos = (int)current_Status.PlayingPosition;
                int len = current_Status.Track.Length;
                retVal.playTime = String.Format("{0}:{1:D2}/{2}:{3:D2}", pos / 60, pos % 60, len / 60, len % 60);
            }
            Debug.Print("Spotify Status Information:");
            Debug.Print("\tIs Playing?: " + current_Status.Playing);
            Debug.Print("\tIs Online?: " + current_Status.Online);
            Debug.Print("\tIs Private Session?: " + current_Status.OpenGraphState.PrivateSession);
            retVal.playing        = current_Status.Playing;
            retVal.online         = current_Status.Online;
            retVal.privateSession = current_Status.OpenGraphState.PrivateSession;

            return(retVal);
        }
 public void setMediaPlayerDetails(MediaPlayerDetails mpd)
 {
     m_playerDetails = mpd;
 }