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 IOS crash when entering Full Screen #1755

Merged
merged 8 commits into from
Mar 27, 2024

Conversation

ne0rrmatrix
Copy link
Contributor

  • Bug fix

Description of Change

The most significant changes involve the removal of the MediaElementUnloaded method and the Unloaded event handler from the MediaElementPage.xaml.cs and MediaElementPage.xaml files respectively. These were previously used to disconnect the handler when the media element was unloaded. Additionally, the OnNavigatedFrom method in the MediaElementPage.xaml.cs file was updated to stop the media element from playing when navigation away from the page occurs.

List of changes:

  1. Removal of the MediaElementUnloaded method from the MediaElementPage.xaml.cs file. This method was previously used to disconnect the handler when the media element was unloaded.
  2. Update to the OnNavigatedFrom method in the MediaElementPage.xaml.cs file to include a call to MediaElement.Stop(). This stops the media element from playing when navigation away from the page occurs.
  3. Removal of the Unloaded event handler from the MediaElementPage.xaml file. This event handler was previously used to call the MediaElementUnloaded method when the media element was unloaded.

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

While adding Full Screen controls an unloaded event was added that called MediaElement.Handler?.Disconnect(); When entering full screen on IOS this event was called. I do not know why IOS calls unload event for switching to or from full screen it just does. This issue is an IOS only issue. It does not affect Mac.

I have tested this PR against Windows, Mac Catalyst, IOS and Android with almost no issues. For unknown reasons when returning to normal mode from full screen on IOS it pauses playback. This does not happen in Mac Catalyst. This is the only issue with this PR atm. I have no idea why IOS pauses upon returning from full screen.

…Unloaded` method and the `Unloaded` event handler from the `MediaElementPage.xaml.cs` and `MediaElementPage.xaml` files respectively. These were previously used to disconnect the handler when the media element was unloaded. Additionally, the `OnNavigatedFrom` method in the `MediaElementPage.xaml.cs` file was updated to stop the media element from playing when navigation away from the page occurs.

List of changes:

1. Removal of the `MediaElementUnloaded` method from the `MediaElementPage.xaml.cs` file. This method was previously used to disconnect the handler when the media element was unloaded.
2. Update to the `OnNavigatedFrom` method in the `MediaElementPage.xaml.cs` file to include a call to `MediaElement.Stop()`. This stops the media element from playing when navigation away from the page occurs.
3. Removal of the `Unloaded` event handler from the `MediaElementPage.xaml` file. This event handler was previously used to call the `MediaElementUnloaded` method when the media element was unloaded.
@ne0rrmatrix ne0rrmatrix marked this pull request as ready for review March 15, 2024 12:12
@vhugogarcia
Copy link
Contributor

Hello @ne0rrmatrix , on this PR there is only changes on the sample application of the Community Toolkit Media Element. Per what I understand the issue is on the sample only? 🤔

@briankanelson, could you please confirm, if the changes applied by James at the XAML page help you the fix the issue on your project: #1110 (comment) ?

@ne0rrmatrix
Copy link
Contributor Author

Hello @ne0rrmatrix , on this PR there is only changes on the sample application of the Community Toolkit Media Element. Per what I understand the issue is on the sample only? 🤔

@briankanelson, could you please confirm, if the changes applied by James at the XAML page help you the fix the issue on your project: #1110 (comment) ?

Yes @vhugogarcia it is only a fix to sample app.

Copy link
Contributor

@vhugogarcia vhugogarcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested these changes and I can confirm, it fixes the iOS crash on the Media Element sample when entering full screen. Thanks @ne0rrmatrix for the help!

@brminnick brminnick enabled auto-merge (squash) March 27, 2024 14:23
@brminnick brminnick merged commit eaf72cb into CommunityToolkit:main Mar 27, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] MediaElement 1.0.2 crashes on iOS when exiting full screen mode and using AppShell
4 participants