Skip to content

[BUG] iOS: MediaElement plays at 1x after Play(), auto-play or loop while Speed reports the requested value #3326

Closed

Description

@ne0rrmatrix

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

On iOS, MediaElement starts or resumes playback at 1x whenever it calls AVPlayer.Play(), regardless of MediaElement.Speed. Speed keeps reporting the requested value, so the property and the actual playback rate disagree.

Measured on main (c8740a8), iPhone 17 simulator, iOS 26.5, with a 24.87s local MP4 (the loop row uses a 3.89s MP3):

Scenario Speed reports Actual playback
ShouldAutoPlay = false, Speed = 2, then Play() 2 1x (position 2.81s after 3s)
Playing at Speed = 2, then Pause() and Play() 2 1x (1.91s of media in 2s)
Playing at Speed = 2, then Stop() and Play() 2 1x (1.83s after 2s)
ShouldAutoPlay = true with Speed = 2 set before loading 2 1x (1.76s after 2s)
ShouldLoopPlayback = true, Speed = 2, after the first loop 2 1x (each loop takes about 4s)

There are two causes:

  1. MediaManager.macios.cs calls Player.Play() in PlatformPlay, in the auto-play path of PlatformUpdateSource and in PlayedToEnd (looping). AVPlayer.Play() starts playback at a rate of 1, and nothing reapplies MediaElement.Speed.
  2. MediaManager.AreFloatingPointNumbersEqual is inverted. It returns Math.Abs(number1 - number2) > tolerance, which is true when the numbers are different. RateChanged in MediaManager.macios.cs guards on !AreFloatingPointNumbersEqual(MediaElement.Speed, Player.Rate), so it only assigns MediaElement.Speed = Player.Rate when the two are already equal. The player's rate is therefore never synced back to Speed, which is why Speed keeps reporting 2 above.

The inverted helper also affects Android:

  • OnPlaybackParametersChanged in MediaManager.android.cs returns when the speeds differ and assigns only when they are equal, so it never updates Speed.
  • PlatformUpdateShouldMute only refreshes volumeBeforeMute when it already equals Player.Volume. A Volume set before the handler connects is lost: on an Android 17 emulator, a MediaElement created with Volume = 0.3 reports Volume 1.00 once playing.

Windows is not affected: OnPlaybackSessionPlaybackRateChanged calls the helper without negation, so it behaves correctly given the inverted result.

Expected Behavior

  • Play(), auto-play and loop restarts play at MediaElement.Speed on iOS and Mac Catalyst.
  • AreFloatingPointNumbersEqual returns true when the numbers are within the tolerance.
  • A Volume set before the handler connects is kept on Android.

Steps To Reproduce

  1. Add a MediaElement with ShouldAutoPlay="False", Speed="2" and a video source.
  2. Run on iOS and wait for the media to load.
  3. Call mediaElement.Play().
  4. Compare Position with elapsed time: it advances at 1x, while Speed still reads 2.
var mediaElement = new MediaElement
{
	ShouldAutoPlay = false,
	Speed = 2,
	Source = MediaSource.FromResource("AppleVideo.mp4")
};

// after the media has loaded
mediaElement.Play();

// 3 seconds later: mediaElement.Position is about 3s (expected about 6s), mediaElement.Speed is 2

Link to public reproduction project repository

https://github.com/CommunityToolkit/Maui

There is no separate reproduction repository. The numbers above come from a small test app that references CommunityToolkit.Maui.MediaElement from main and runs the snippet in Steps To Reproduce, using the AppleVideo.mp4 resource from the sample app.

Environment

- .NET MAUI CommunityToolkit: main (c8740a8)
- OS: iOS 26.5 (iPhone 17 simulator); Android 17 emulator for the Volume finding
- .NET MAUI: 10.0.90
- .NET SDK: 10.0.401
- Xcode: 26.6

Anything else?

Not verified: Mac Catalyst (same code as iOS, not run) and a physical device.

Related: #1668 reported the same symptom for Play() on iOS and was closed as completed.

Activity

  1. added a commit that references this issue on Oct 4, 2026
    70f48c5
  2. locked and limited conversation to collaborators on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working📽️ MediaElementIssue/PR that has to do with MediaElement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions