Maui: [BUG] PositionChanged not being fired after loading local file from C#

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

After specifying a source in the C# backend, the MediaElement no longer reports the position of the video and PositionChanged never fires.

Expected Behavior

When the video is playing, or the SeekTo() is complete, the PositionChanged method should fire and the correct position of the video player should be reported.

Steps To Reproduce

Using the CommunityToolkit.Maui.Sample project, remove the Source of the MediaElement control from the XAML. Use the button to change the Source of the MediaElement to any other element. The Position no longer updates in the label, and the slider no longer works. Screenshot_20231120_130608

Link to public reproduction project repository

https://github.com/VideoSystems/repos

Environment

- .NET MAUI CommunityToolkit: 7.0.0, MediaElement: 3.0.0
- OS: Windows 11 Build 22621.2715
- .NET MAUI: 8.0.3

Anything else?

If you specify the source of the MediaElement in the MainPage() method, then the Position works just like specifying in the XAML.

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@pictos it was updated a few minutes after I made that comment by @brminnick to keep it open.

Another note using sample app and selecting any item in source menu will have same effect. So both xaml and code behind will result in position not being tracked. It only works once. This does not affect windows at all. IOS, android both affected. Was unable to test on Mac with sample app. On mac the sample app menu for source fails to load. The issue with menu appears to an issue with Microsoft.Maui.Controls and nothing to do with position bug.

I’m having the same issue. @ne0rrmatrix Thanks for the fix and hopefully the NuGet update will be released soon

Hi, I can confirm that after upgrading my MediaElement from version 2 to 3 the problem with Position not being updated appeared on Android. Also PositionChanged is not being fired up. No problem on Windows though. Hopefully, this can be solved quickly as there are no alternative media players for MAUI. There is an option to revert to version 2, but this is not the direction we should sail, right?

I have been looking into this. I can confirm with Toolkit sample. If you switch sources position tracking stops working. Not an issue for windows. For android changing sources causes position tracking to break. But duration works fine. On IOS both position and duration are not working when you switch sources. This is tested against main.

edit: Tried testing on Mac. Was unable to verify as clicking on menu item to select source failed to work. Not sure but that appears to be unrelated issue. Will try manually doing in code behind to test. All testing was done against main as of November 21 2023.