public void setMediaPlayerDetails(MediaPlayerDetails mpd)
 {
     m_playerDetails = mpd;
 }
示例#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;
            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;
        }