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 Android Layout #1814

Merged

Conversation

ne0rrmatrix
Copy link
Contributor

@ne0rrmatrix ne0rrmatrix commented Apr 12, 2024

Bug fix

Description of Change

Fixes the android layout issue that has been present since full screen support was added. We had switched layouts to use a frame layout. Now we have switched back to using a relative layout. This should fix the issue of layouts not behaving correctly.

Linked Issues

PR Checklist

Additional information

  1. The WidthRequest attribute of the MediaElement toolkit was removed from MediaElementPage.xaml. This attribute was previously used to set the width of the media element based on the device type (tablet or default).

  2. The Activity attribute in MainActivity.cs was modified to include ResizeableActivity = true. This change allows the activity to be resizable.

  3. In MauiMediaElement.android.cs, the Android.Util namespace was added to the import statements. Two new integer variables playerHeight and playerWidth were added to the MauiMediaElement class. These variables are used to store the height and width of the player view.

  4. The OnFullscreenButtonClick method of the MauiMediaElement class was updated. The new code stores the current player view's height and width, retrieves the display metrics, removes the player view from its current layout, and adds it to a new layout with updated parameters. The code for exiting fullscreen mode was also updated to restore the player view to its original size and layout.

  5. In MediaManager.android.cs, the import statement for AndroidX.CoordinatorLayout.Widget was removed. The LayoutParameters attribute of the PlayerView object was changed from FrameLayout.LayoutParams to RelativeLayout.LayoutParams. This change aligns with the updates made in the MauiMediaElement class, where the player view is now added to a RelativeLayout instead of a FrameLayout.

ne0rrmatrix and others added 3 commits April 12, 2024 13:46
…WidthRequest` attribute in `MediaElementPage.xaml`, the addition of the `ResizeableActivity = true` attribute in `MainActivity.cs`, and the modification of the `OnFullscreenButtonClick` method in the `MauiMediaElement` class.

1. The `WidthRequest` attribute of the `MediaElement` toolkit was removed from `MediaElementPage.xaml`. This attribute was previously used to set the width of the media element based on the device type (tablet or default).

2. The `Activity` attribute in `MainActivity.cs` was modified to include `ResizeableActivity = true`. This change allows the activity to be resizable.

3. In `MauiMediaElement.android.cs`, the `Android.Util` namespace was added to the import statements. Two new integer variables `playerHeight` and `playerWidth` were added to the `MauiMediaElement` class. These variables are used to store the height and width of the player view.

4. The `OnFullscreenButtonClick` method of the `MauiMediaElement` class was updated. The new code stores the current player view's height and width, retrieves the display metrics, removes the player view from its current layout, and adds it to a new layout with updated parameters. The code for exiting fullscreen mode was also updated to restore the player view to its original size and layout.

5. In `MediaManager.android.cs`, the import statement for `AndroidX.CoordinatorLayout.Widget` was removed. The `LayoutParameters` attribute of the `PlayerView` object was changed from `FrameLayout.LayoutParams` to `RelativeLayout.LayoutParams`. This change aligns with the updates made in the `MauiMediaElement` class, where the player view is now added to a `RelativeLayout` instead of a `FrameLayout`.
@brminnick brminnick added approved This Proposal has been approved and is ready to be added to the Toolkit pending documentation This feature requires documentation labels Apr 27, 2024
@brminnick brminnick enabled auto-merge (squash) April 29, 2024 19:33
@brminnick brminnick merged commit 971842b into CommunityToolkit:main Apr 29, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This Proposal has been approved and is ready to be added to the Toolkit pending documentation This feature requires documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media Element does not center vertically inside Absolute Layout (android)[BUG]
2 participants