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

[Proposal] API that allows developers to hook a media element event and know the full screen status. #1927

Open
6 of 8 tasks
Neotrickster opened this issue Jun 11, 2024 · 1 comment · May be fixed by #2041
Open
6 of 8 tasks
Assignees
Labels
approved This Proposal has been approved and is ready to be added to the Toolkit champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature 📽️ MediaElement Issue/PR that has to do with MediaElement pending documentation This feature requires documentation proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail

Comments

@Neotrickster
Copy link

Neotrickster commented Jun 11, 2024

Feature name

VideoPlayer_FullScreenStatusChanged

Link to discussion

#1748 (comment)

Progress tracker

  • Android Implementation
  • iOS Implementation
  • MacCatalyst Implementation
  • Windows Implementation
  • Tizen Implementation
  • Unit Tests
  • Samples
  • Documentation

Summary

API that allows developers to hook a media element event and know the full screen status.
Is it full screen or normal ?

Motivation

In Xamarin times, we already have something to control when the Full Screen status changed (first and third party) and now we have a very mature Media Element in MAUI is about time to start with this.

Detailed Design

/// <summary>
/// Backing store for the <see cref="FullScreenState"/> property.
/// </summary>
public static readonly BindableProperty FullScreenProperty =
	BindableProperty.Create(nameof(FullScreenState), typeof(MediaElementScreenState), typeof(MediaElement), 
	MediaElementScreenState.Default, propertyChanged: OnFullScreenPropertyChanged);

Usage Syntax

public MediaElementPage(MediaElementViewModel viewModel, ILogger<MediaElementPage> logger) : base(viewModel)
{
	InitializeComponent();
	MediaElement.FullScreenStateChanged += MediaElement_FullScreenStateChanged;
}
        
void MediaElement_FullScreenStateChanged(object? sender, FullScreenStateChangedEventArgs e) =>
	logger.LogInformation("FullScreen State Changed. Old State: {PreviousState}, New State: {NewState}", e.PreviousState, e.NewState);

Drawbacks

I don't see any reason to not do it :)

Alternatives

Before I migrate to MAUI MediaElement I was using Xamarin with Xamarians/MediaPlayer [https://github.com/Xamarians/MediaPlayer] , looks simple enough from a use perspective:

public partial class SegnalesEnVivoPage : ContentPage
{
		InitializeComponent();
		BindingContext = new SegnalesEnVivoViewModel();

		VideoPlayer.FullScreenStatusChanged += VideoPlayer_FullScreenStatusChanged;
}

private void VideoPlayer_FullScreenStatusChanged(object sender, bool value)
{
			NavigationPage.SetHasNavigationBar(this, !value);
			Shell.SetNavBarIsVisible(this, !value);
			frmInformation.IsVisible = !value;
			frmBackground.IsVisible = !value;
			frmPlayer.Margin = value ? new Thickness(0, 0, 0, 0) : new Thickness(10, 20, 10, 10);
			VideoPlayer.HeightRequest = value ? deviceScreenHeight : 240;
			InvalidateMeasure();
		}

}

Unresolved Questions

Perhaps the above API is a good v1 if it works on all platforms?
And then we iterate on more functionality in later versions?

@Neotrickster Neotrickster added new proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail labels Jun 11, 2024
@brminnick brminnick added the needs discussion Discuss it on the next Monthly standup label Jun 12, 2024
@ne0rrmatrix
Copy link
Contributor

That looks great! I have done the initial work to test and it does indeed work. I have it working for Android, Windows, iOS, and Mac Catalyst. So if we move ahead with this API all that is needed is for me to finish editing and then create PR and have it reviewed. Here is link to branch with required changes already done. https://github.com/ne0rrmatrix/MauiOld/tree/FullScreenEvents

@vhugogarcia vhugogarcia added the 📽️ MediaElement Issue/PR that has to do with MediaElement label Jun 20, 2024
@brminnick brminnick added approved This Proposal has been approved and is ready to be added to the Toolkit champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature and removed new labels Jul 12, 2024
@ne0rrmatrix ne0rrmatrix linked a pull request Jul 19, 2024 that will close this issue
6 tasks
@github-project-automation github-project-automation bot moved this to Proposal Approved in New Feature Proposals Aug 29, 2024
@brminnick brminnick added pending documentation This feature requires documentation and removed needs discussion Discuss it on the next Monthly standup labels Sep 5, 2024
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 champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature 📽️ MediaElement Issue/PR that has to do with MediaElement pending documentation This feature requires documentation proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail
Projects
Status: Proposal Approved
Development

Successfully merging a pull request may close this issue.

5 participants