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

Full Screen Events #446

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/maui/views/MediaElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,33 @@ The `Aspect` property determines how video media will be scaled to fit the displ
- `AspectFill` indicates that the video will be clipped so that it fills the display area, while preserving the aspect ratio.
- `Fill` indicates that the video will be stretched to fill the display area.

## Determine Media Screen status

The `mediaElement` class defines a read-only bindable property named `FullScreenState` of type `MediaElementScreenState`. This property indicates the current status of the control, such as whether the player is in full screen or default state.

The `MediaElementScreenState` enumeration defines the following members:
- `FullScreen` indicates the `MediaElement` is in full screen mode.
- `Default` indicates the `MediaElement` is in default mode.

## Implement Media Screen status controls

To retrieve the current `MediaElement` screen status, you can use the `FullScreenState` property. The screen status is a read-only property. You cannot enter or exit full screen mode programmatically. To track the change in `MediaElementScreenState`, you can use the `MediaElement.FullScreenStateChanged` event. The Following XAML shows a page that contains a `MediaElement` and an event handler that is invoked when the `MediaElement` enters or exits full screen mode.

```xaml
<toolkit:MediaElement
x:Name="MediaElement"
ShouldAutoPlay="True"
Source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
FullScreenStateChanged="MediaElement_FullScreenStateChanged"/>
```

The code-behind file has the handlers for the `MediaElement` events.

```csharp
void MediaElement_FullScreenStateChanged(object? sender, FullScreenStateChangedEventArgs e) =>
logger.LogInformation("FullScreen State Changed. Old State: {PreviousState}, New State: {NewState}", e.PreviousState, e.NewState);
```

## Determine `MediaElement` status

The `MediaElement` class defines a read-only bindable property named `CurrentState`, of type `MediaElementState`. This property indicates the current status of the control, such as whether the media is playing or paused, or if it's not yet ready to play the media.
Expand Down Expand Up @@ -466,6 +493,7 @@ To read more about handlers, please see the .NET MAUI documentation on [Handlers
| MediaFailed | Occurs when there's an error associated with the media source. |
| PositionChanged | Occurs when the `Position` property value has changed. |
| SeekCompleted | Occurs when the seek point of a requested seek operation is ready for playback. |
| FullScreenStateChanged | Occurs when entering or exiting full screen mode. |

## Methods

Expand Down