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 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" Condition=" '$(Configuration)'=='Release' " PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="ResourceDictionary.windows.xaml">
<LogicalName>ResourceDictionary.windows.xaml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace CommunityToolkit.Maui.Primitives;

sealed partial class CustomTransportControls : MediaTransportControls
{
public event EventHandler<EventArgs>? OnTemplateLoaded;
public AppBarButton FullScreenButton = new();
bool isFullScreen = false;

public CustomTransportControls()
{
this.DefaultStyleKey = typeof(CustomTransportControls);
}

protected override void OnApplyTemplate()
{
base.OnApplyTemplate();

var temp = GetTemplateChild("FullWindowButton") as AppBarButton;
if(temp is not null)
{
FullScreenButton = temp;
FullScreenButton.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
OnTemplateLoaded?.Invoke(this, EventArgs.Empty);
FullScreenButton.Click += FullScreenButton_Click;
}
}

void FullScreenButton_Click(object sender, RoutedEventArgs e)
{
if (isFullScreen)
{
FullScreenButton.Icon = new FontIcon { Glyph = "\uE740" };
isFullScreen = false;
}
else
{
FullScreenButton.Icon = new SymbolIcon(Symbol.BackToWindow);
isFullScreen = true;
}
}
}
Loading
Loading