You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] MediaElement on iOS and Mac Catalyst publishes a non-zero playback rate to Now Playing while paused #3383
On iOS and Mac Catalyst, MediaElement publishes a non-zero playback rate to the system's Now Playing info while playback is paused.
Metadata.SetMetadata sets NowPlayingInfo.PlaybackRate = mediaElement.Speed (Metadata.macios.cs, line 96).
MediaManager.macios.cs calls it whenever the player's TimeControlStatus changes, including to Paused (line 977), and the rate observer publishes PlaybackRate = MediaElement.Speed again (line 1071).
A pause doesn't change Speed (by design; MediaManagerSpeedAppleTests.NativePauseDoesNotChangeTheSpeed covers it), so the published rate stays 1.0 (or the chosen speed) while paused.
The system computes the lock screen's elapsed time from the last ElapsedPlaybackTime and the playback rate, and a rate of 0 is how the Now Playing info says "paused". So the lock screen and Control Center may show paused media as playing, with the elapsed time still advancing.
This was found by reading the code during #3344's review; it is not yet confirmed on a device. The code has been this way since #1782 (June 2024).
Expected Behavior
While MediaElement is paused or stopped, the Now Playing info has PlaybackRate = 0 and the current ElapsedPlaybackTime, so the lock screen and Control Center show it as paused at the right position. While playing, the rate is Speed.
Steps To Reproduce
Run CommunityToolkit.Maui.Sample on an iPhone (a device shows the lock screen controls most reliably).
Open Views > MediaElements Page > MediaElement, start a video, and set a speed if you like.
Pause it in the app.
Lock the iPhone, or open Control Center, and look at the Now Playing controls.
Expected: paused, elapsed time not moving. Suspected: shown as playing, elapsed time advancing.
- .NET MAUI CommunityToolkit: main (991e2cba), CommunityToolkit.Maui.MediaElement
- OS: iOS and Mac Catalyst (Metadata.macios.cs)
- .NET MAUI: 10.0.90
Anything else?
A possible fix: publish PlaybackRate = 0 (with the current ElapsedPlaybackTime) when TimeControlStatus is Paused or the state is Stopped, and Speed only while playing; a device test can check MPNowPlayingInfoCenter.DefaultCenter.NowPlaying after a pause. The Windows and Android metadata may deserve the same check.
Activity
Publish a playback rate of 0 to Now Playing while MediaElement is pau…