Maui
Maui copied to clipboard
Fix Media Element fails to load a URL
- Bug fix
Description of Change
Updated the Dispose method in MauiMediaElement.windows.cs to include:
- Pausing the media player before disposal.
- Explicitly disposing of MediaSource if used.
- Setting the media player's source to null.
- Disposing of the media player.
- Setting the media player element's media player to null.
These changes ensure proper release of resources, preventing memory leaks.
Linked Issues
- Fixes #2264
PR Checklist
- [x] Has a linked Issue, and the Issue has been
approved
(bug) orChampioned
(feature/proposal) - [ ] Has tests (if omitted, state reason in description)
- [x] Has samples (if omitted, state reason in description)
- [x] Rebased on top of
main
at time of PR - [x] Changes adhere to coding standard
- [x] Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls
Additional information
This PR fixes an issue where upon entering and leaving a page 3 times results in Media Element failing to load any URL and showing blank controls with no buttons in Windows environment. This does not fix the issue with being unable to renter the page a second time without visiting a different page. Can be any page including other media element pages. Just not the same one.