CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.29k stars 404 forks source link

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

Closed VideoSystems closed 12 months ago

VideoSystems commented 1 year ago

Is there an existing issue for this?

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.

ghost commented 1 year ago

Hi @VideoSystems. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

VideoSystems commented 1 year ago

Apologies, here's a gihub link to a small example project that highlights the issue: https://github.com/VideoSystems/repos

ne0rrmatrix commented 1 year ago

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.

ne0rrmatrix commented 1 year ago

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.

zabanet commented 1 year ago

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?

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

ne0rrmatrix commented 1 year ago

Can someone mark this as open and not close it till my PR gets reviewed please? @pictos ? The OP did add a sample repo but did it as a reply and not as an edit.

pictos commented 1 year ago

@ne0rrmatrix which issue are you talking about? This one remains opened

ne0rrmatrix commented 1 year ago

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

VideoSystems commented 1 year ago

This is my first post on GitHub, not sure if I'm required to take further action to progress this issue, but am happy to do whatever needed in terms of review or updates to get this solved.

@ne0rrmatrix , I see that you've made the edits to the code to get the Position working again. I'm using NuGet to get the MediaElement, do I simply need to wait until the next release to get the updated code in my project? Is there a different way I can/need to get the updates?

ne0rrmatrix commented 1 year ago

@VideoSystems welcome to the community. If you want you can download the PR and build it yourself and see if it fixes your issue. If you are not comfortable building the project yourself it will be out soon. I am waiting on a maintainer to look at it and verify that the code I submitted meets the code standards and does what it is supposed to. I imagine by the end of this week or early next week it should be merge to main. Fingers crossed.

You can also look at https://github.com/CommunityToolkit/Maui/wiki/Preview-Packages and learn more about how to use Pull requests as a nuget. There are two feeds on that page from azure. Latest which is the main feed. The pull request feed is the one where you can grab this PR.

VideoSystems commented 1 year ago

Fantastic! Thanks for the information! 😁

yureng commented 1 year ago

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

DamianMehers commented 12 months ago

I've hit the same issue - is it really unverified? Can we remove that tag?

VideoSystems commented 12 months ago

It seems that @ne0rrmatrix was able to verify the issue and created a fix for it. Not sure how to get the tag changed though. Anxiously awaiting the new release with the fix!