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

Update MediaElement Transport Controls for Windows #2329

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

Conversation

ne0rrmatrix
Copy link
Contributor

@ne0rrmatrix ne0rrmatrix commented Nov 9, 2024

  • Feature/Proposal

Description of Change

Update MediaElement Transport Controls for Windows. Adds Support for Full Screen button in the controls. Controls are updated to have play, pause, Fast Forward, Next, Previous, Inline Volume Controls, Repeat button, Cast Button and an Aspect button.

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 updates the windows controls to support all the Media Buttons you could want.

image

image

Introduced a new embedded resource, `ResourceDictionary.windows.xaml`, in the `CommunityToolkit.Maui.MediaElement.csproj` project file.

Updated `MauiMediaElement.windows.cs`:
- Imported new namespaces.
- Added `CustomTransportControls` field and methods for loading resource dictionary and applying custom styles.
- Updated constructor to load resource dictionary and set custom transport controls.
- Added `LoadResourceDictionary`, `ApplyCustomStyle`, and `SetTransportControls` methods.
- Updated `Dispose` method to handle custom transport controls.
- Removed `OnMediaPlayerElementPointerMoved` method and related code.
- Updated `OnFullScreenButtonClick` method to remove fullscreen button references.

Updated `MediaManager.windows.cs`:
- Disabled `SystemMediaTransportControls` in `CreatePlatformView`.

Added `CustomTransportControls` class in `CommunityToolkit.Maui.Primitives`:
- Imported necessary namespaces.
- Defined `FullScreenButton` property.
- Implemented `OnTemplateLoaded` event.
- Overrode `OnApplyTemplate` method to add full-screen button.
- Added `FullScreenButton_Click` event handler.
- Introduced `isFullScreen` field to track full-screen state.
Moved RightSeparator before PlaybackRateButton in ResourceDictionary.windows.xaml. Added RightSeparator with Height='0', Width='0', and Margin='0,0'. Reordered properties of PlaybackRateButton without changing values. Removed original RightSeparator after PlaybackRateButton.
Re-added various properties and elements to styles and templates in `ResourceDictionary.windows.xaml` to ensure consistent UI appearance and behavior. Added new buttons like `ZoomButton` and `CastButton` to the media controls command bar. Enhanced `customTransportcontrols` and `CommandBarStyle` with additional properties.
Removed the `UseLayoutRounding` property and adjusted the `Margin`
property from `0,0,0,20` to `0,0,0,10`. Added `VerticalContentAlignment`
set to `Center` and `VerticalAlignment` set to `Bottom`. Introduced
`CornerRadius` of `8,8,8,8` to the `Grid` element in the
`ResourceDictionary.windows.xaml` file.
- Cleaned up `using` directives by removing redundant `using CommunityToolkit.Maui.Core;` and reordering the remaining directives.
- Changed `CustomTransportControls` class from public sealed to sealed partial.
- Removed XML documentation comments for `CustomTransportControls` class and its members.
- Changed `FullScreenButton` property from nullable `AppBarButton` with a private setter to non-nullable `AppBarButton` initialized with a new instance.
- Removed null check for `FullScreenButton` in `FullScreenButton_Click` method as `FullScreenButton` is no longer nullable.
@ne0rrmatrix ne0rrmatrix added the 📽️ MediaElement Issue/PR that has to do with MediaElement label Nov 9, 2024
@ne0rrmatrix ne0rrmatrix marked this pull request as ready for review November 11, 2024 23:20
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.

1 participant