Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Media Element fails to load a URL #2265

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ne0rrmatrix
Copy link
Contributor

  • 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

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • 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.

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.
@ne0rrmatrix ne0rrmatrix added the 📽️ MediaElement Issue/PR that has to do with MediaElement label Oct 7, 2024
@ne0rrmatrix ne0rrmatrix marked this pull request as draft October 7, 2024 23:32
@ne0rrmatrix ne0rrmatrix marked this pull request as ready for review October 8, 2024 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📽️ MediaElement Issue/PR that has to do with MediaElement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] MediaSource not Disposed on Exit
1 participant