Show now playing metadata on macOS even without a known duration#290
Open
SandFoxy wants to merge 1 commit into
Open
Show now playing metadata on macOS even without a known duration#290SandFoxy wants to merge 1 commit into
SandFoxy wants to merge 1 commit into
Conversation
updateDisplay() withheld the entire MPNowPlayingInfoCenter dictionary (title, artist, artwork) whenever the current track's duration was unknown or zero, because it published the info dictionary only when both `enabled` and `duration()` were set. At the same time setPlaybackStatus() had already assigned the global MPNowPlayingInfoCenter.playbackState, so the system still registered the app as the active player. As a result macOS Control Center, the lock screen and the media keys HUD showed that Telegram was playing something, but without any track title, artist or artwork. The duration is not always available: it stays zero for audio without a duration attribute and during the short window before the media header is parsed, and there is no later re-publish once it becomes known. Gate updateDisplay() on `enabled` only. That flag already tracks whether there is active media (it is turned off together with clearMetadata() when playback stops), so the metadata is published as soon as media is playing. This also matches the Windows and Linux backends, which never gate the metadata on the duration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS the Control Center, lock screen and media-keys HUD showed that Telegram was playing audio but without any track title, artist or artwork.
updateDisplay()published theMPNowPlayingInfoCenterdictionary only when bothenabledandduration()were set, whilesetPlaybackStatus()assigns the globalMPNowPlayingInfoCenter.playbackStateunconditionally — so the app was registered as the active player even though its info dictionary wasnil. The duration is not always available (audio without a duration attribute, or the short window before the media header is parsed, with no later re-publish), which produced the "playing, but no info" state.Gate
updateDisplay()onenabledonly — that flag already tracks whether there is active media and is cleared together withclearMetadata()on stop. This also matches the Windows and Linux backends, which never gate the metadata on the duration.