Exemple #1
0
        private void UpdatePresence()
        {
            if (_iTunes.CurrentPlaylist.Kind == ITPlaylistKind.ITPlaylistKindUser)
            {
                if (((IITUserPlaylist)_iTunes.CurrentPlaylist).SpecialKind == ITUserPlaylistSpecialKind.ITUserPlaylistSpecialKindMusic)
                {
                    _currentPlaylistType = "Album";
                    _currentPlaylist     = _iTunes.CurrentTrack.Album;
                }
                else
                {
                    _currentPlaylistType = "Playlist";
                    _currentPlaylist     = _iTunes.CurrentPlaylist.Name;
                }
            }
            else
            {
                _currentPlaylistType = "Album";
                _currentPlaylist     = _iTunes.CurrentTrack.Album;
            }

            var presence = new DiscordRPC.RichPresence {
                largeImageKey = "itunes_logo_big"
            };

            if (_currentState != ITPlayerState.ITPlayerStatePlaying)
            {
                presence.details = TruncateString(RenderString(Properties.Settings.Default.PausedDetailsFormat));
                presence.state   = TruncateString(RenderString(Properties.Settings.Default.PausedStateFormat));
            }
            else
            {
                presence.details        = TruncateString(RenderString(Properties.Settings.Default.DetailsFormat));
                presence.state          = TruncateString(RenderString(Properties.Settings.Default.StateFormat));
                presence.startTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds() - _iTunes.PlayerPosition;
                presence.endTimestamp   = DateTimeOffset.Now.ToUnixTimeSeconds() + (_iTunes.CurrentTrack.Duration - _iTunes.PlayerPosition);
            }

            DiscordRPC.UpdatePresence(presence);
        }
        private void UpdatePresence()
        {
            var presence = new DiscordRPC.RichPresence {
                details = $"{_currentArtist} - {_currentTitle}"
            };

            if (_currentTitle == "DVNO")
            {
                presence.largeImageKey  = "dvno";
                presence.smallImageKey  = "itunes_logo";
                presence.largeImageText = "Four capital letters, printed in gold";
            }
            else
            {
                presence.largeImageKey = "itunes_logo_big";
            }

            if (_iTunes.CurrentPlaylist.Kind == ITPlaylistKind.ITPlaylistKindUser)
            {
                presence.state = _iTunes.CurrentPlaylist.Name == "Music"
                    ? $"Album: {_iTunes.CurrentTrack.Album}"
                    : $"Playlist: {_iTunes.CurrentPlaylist.Name}";
            }
            else
            {
                presence.state = $"Album: {_iTunes.CurrentTrack.Album}";
            }

            if (_currentState != ITPlayerState.ITPlayerStatePlaying)
            {
                presence.state = "Paused";
            }

            presence.startTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds() - _iTunes.PlayerPosition;
            presence.endTimestamp   = DateTimeOffset.Now.ToUnixTimeSeconds() + (_iTunes.CurrentTrack.Duration - _iTunes.PlayerPosition);

            DiscordRPC.Discord_UpdatePresence(ref presence);
        }