Open
Conversation
This commit introduces full screen state management for media elements. The `CommunityToolkit.Maui.Primitives` namespace was added to several files to support this feature. A new `MediaElementScreenState` enum and `FullScreenStateChangedEventArgs` class were added to represent the full screen state and event data respectively. The `IMediaElement` and `MediaElement` interfaces were updated to include a `FullScreenState` property, a `FullScreenStateChanged` event, and a `FullScreenChanged` method. The `MediaElementPage` class now subscribes to the `FullScreenStateChanged` event and logs information when triggered. The `MauiMediaElement` classes for Android and Windows, and the `MediaManagerDelegate` class for MacOS, were updated to include a `WindowsChanged` event that triggers when the full screen state changes. The `MediaManager` classes for Android, MacOS, and Windows now subscribe to the `WindowsChanged` event and update the full screen state when triggered. The `MediaManager` class for MacOS sets the `Delegate` property of the `AVPlayerViewController` to a new instance of `MediaManagerDelegate`.
- Updated MediaElementPage.xaml to include a new event handler `FullScreenStateChanged` for better responsiveness to fullscreen changes. - Removed subscription to `FullScreenStateChanged` in MediaElementPage.xaml.cs, indicating a shift in how fullscreen changes are managed. - Improved Android fullscreen support in MauiMediaElement.android.cs by invoking `OnWindowsChanged` with `FullScreenStateChangedEventArgs` to accurately track fullscreen state changes.
Updated the comment for the `OnWindowsChanged` static event in the `MediaManager` class to more accurately describe its purpose related to changes in the full screen state of the media element. The previous, less descriptive comment was replaced with a clearer explanation.
…iOld into FullScreenEvents
This commit overhauls the handling of full-screen state changes across Android, Windows, and macOS within a Maui application. A new record, `FullScreenEvents`, has been introduced in the `MediaManager` class to centralize event handling, replacing platform-specific `WindowsChanged` events with a unified approach. This refactor includes the removal of redundant `using` directives, adjustments in event invocation to utilize the new centralized event, and general code cleanup for better readability and maintainability. Platform-specific code has been updated to align with this new mechanism, streamlining the full-screen state change process across different operating systems.
…iOld into FullScreenEvents
- Removed `OnWindowsChanged` from `MediaManager` in platform-specific files (Android, macOS, Windows) due to redundancy and centralized this logic by adding a new protected method `OnWindowsChanged` to the `FullScreenEvents` record in `MediaManager.shared.cs`. This change aims to reduce code duplication and improve the management of full-screen state changes across different platforms.
Centralized the subscription to FullScreenEvents.WindowsChanged in the MediaManager class to improve maintainability and readability. Removed redundant event unsubscriptions in platform-specific MediaManager files, streamlining event management.
- Renamed `OnWindowsChanged` to `OnFullScreenStatusChanged` in `MediaManager` and `FullScreenEvents` for clarity. - Added `MediaElement` property to `FullScreenEvents` for better media element access.
In `MauiMediaElement.android.cs`, the visibility of `CurrentPlatformContext` has been changed from `readonly` to `public readonly`, enhancing its accessibility for external use. Additionally, in `MediaManager.shared.cs`, a comment has been added to acknowledge similarities with PR CommunityToolkit#1918 on the CommunityToolkit/Maui repository.
- Changed `CurrentPlatformContext` in `MauiMediaElement.android.cs` from `public` to `internal`, limiting its accessibility to within its assembly. - Modified `FullScreenEvents` in `MediaManager.shared.cs`: 1. Access modifier updated from `public` to `internal`. 2. Converted from a `record` to a `readonly record struct`, making it a value type and immutable.
This was referenced Jul 19, 2024
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementScreenState.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Outdated
Show resolved
Hide resolved
Renamed the FullScreenButtonClicked event to FullScreenStateChanged across Android, Windows, and iOS/macOS MediaElement implementations. Updated all event declarations, handler subscriptions, and invocations for consistency and clarity. Also renamed related variables (e.g., mDelegate to fullScreenDelegate) to match the new event naming. This change ensures the event accurately represents any full-screen state change, not just button clicks.
src/CommunityToolkit.Maui.MediaElement/Primitives/ScreenStateChangedEventArgs.cs
Outdated
Show resolved
Hide resolved
Refactored all usages of FullScreenStateChanged event and related types to ScreenStateChanged for improved clarity and generalization. Replaced FullScreenStateChangedEventArgs with ScreenStateChangedEventArgs, updated property and field names, and revised event handler signatures and XAML wiring across all platforms. Updated unit tests to reflect these changes. This makes screen state transitions more semantically accurate and extensible beyond just full screen scenarios.
…hangedEventArgs.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Outdated
Show resolved
Hide resolved
pictos
reviewed
Feb 17, 2026
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Outdated
Show resolved
Hide resolved
…windows.cs Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
…os.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ndler.windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ndler.windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs
Outdated
Show resolved
Hide resolved
…ementTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Show resolved
Hide resolved
Renamed the FullScreenState property and all related references to ScreenState across the codebase. This includes property names, event documentation, method parameters, and all usages in implementation and tests. The change generalizes the state property to better reflect its purpose and potential future use cases beyond just fullscreen.
…iOld into FullScreenEvents
Simplified fullscreen toggle logic by removing unnecessary null checks and direct use of the nullable Value property. Assumes mediaElementState is always set, improving code clarity.
src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementScreenState.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Support for Full Screen Events for Windows, Android, iOS and Mac Catalyst.
Description of Change
Add event handlers to notify developer when full screen status changes.
API:
XAML:
Code Behind:
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
This is a PR to implement a solution for adding support for developers to have an the choice to see when user goes into full full screen and back again.
Note for Maintainers: If you see a need for a name change please go ahead and edit. Names are important. I have no opinion on naming of classes/functions/variables. If you see a need for them to change feel free to make those edits.