VOOZH about

URL: https://www.nuget.org/packages/MediaControls.Maui/

⇱ NuGet Gallery | MediaControls.Maui 1.0.1




MediaControls.Maui 1.0.1

dotnet add package MediaControls.Maui --version 1.0.1
 
 
NuGet\Install-Package MediaControls.Maui -Version 1.0.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MediaControls.Maui" Version="1.0.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MediaControls.Maui" Version="1.0.1" />
 
Directory.Packages.props
<PackageReference Include="MediaControls.Maui" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MediaControls.Maui --version 1.0.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MediaControls.Maui, 1.0.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MediaControls.Maui@1.0.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MediaControls.Maui&version=1.0.1
 
Install as a Cake Addin
#tool nuget:?package=MediaControls.Maui&version=1.0.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MediaControls Is a Custom UI for Dotnet Maui MediaElement

Currently it works with Navigation Page, Tabbed page, and Shell page. Windows, Android, IOS and Mac supported. Full screen is supported by Windows, android and IOS. It is not supported on Mac Catalyst. You can set the page to full screen using MediaControls full screen option which is the image button in upper right of screen. Controls show at start of playback.

Clicking or tapping on page will cause the controls to appear for 7 seconds. In windows double clicking on page will set page to full screen or restore the screen to default size. On Android swiping up will enter full screen and swiping down will exit full screen. If you have MediaControls as only element on page full screen controls will work properly.

You don't need to worry about tab bar, title, or nav bar it will be hidden or shown with state preserved so that if you go full screen then back again it will show the previous state upon restore default page size.

MediaControls.Maui .NET 7 QualityGate
Stable 👁 .NET 7
👁 Quality Gate Status

API Examples:

Play, Pause, Stop, Mute, UnMute, Fast Forward, Rewind, ShowCustomControls, ShouldAutoPlay, ShouldKeepScreenOn, SeekTo, Aspect, Source, ShouldMute

Code Behind Examples

 mediaControl.ShouldMute = false;
 mediaControl.Play();
 mediaControl.Pause();
 mediaControl.Stop();
 mediaControl.ShouldKeepScreenOn = false;
 mediaControl.ShouldAutoPlay = false;
 mediaControl.Aspect = Aspect.AspectFit;
 mediaControl.Source = "https://somevideo.mp4";

Xaml Examples

 <controls:MediaControl
 ShouldAutoPlay="True"
 ShouldKeepScreenOn="True"
 ShowCustomControls="True"
 Source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" />

Example for xaml usage:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
 x:Class="SampleApp.MainPage"
 xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
 xmlns:controls="clr-namespace:MediaControls.Control;assembly=MediaControls">
 <Grid BackgroundColor="Black">
 <controls:MediaControl
 x:Name="mediaControl"
 ShouldAutoPlay="True"
 ShouldKeepScreenOn="True"
 ShowCustomControls="True"
 Source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" />
 </Grid>

</ContentPage>

You need to add the lines below but you do not need to add the packages for CommunityToolkit or MediaElement directly unless you want to use them for something else. But you do need to add the code below in MauiPorgram.cs as described for this to work.

The important part is:

.UseMauiCommunityToolkit().UseFullScreen().UseMauiCommunityToolkitMediaElement().UseMediaControls();

Example for MauiProgram.cs

using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
using MauiPageFullScreen;
using MediaControls;

namespace MauiApp1
{
 public static class MauiProgram
 {
 public static MauiApp CreateMauiApp()
 {
 var builder = MauiApp.CreateBuilder();
 builder.UseMauiApp<App>().ConfigureFonts(fonts =>
 {
 fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
 fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
 }).UseMauiCommunityToolkit().UseFullScreen().UseMauiCommunityToolkitMediaElement().UseMediaControls();
#if DEBUG
 builder.Logging.AddDebug();
#endif
 return builder.Build();
 }
 }
}

On IOS devices plist must be adjusted with included code below:

<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>
Product Versions Compatible and additional computed target framework versions.
.NET net7.0-android33.0 net7.0-android33.0 is compatible.  net7.0-ios16.1 net7.0-ios16.1 is compatible.  net7.0-maccatalyst16.1 net7.0-maccatalyst16.1 is compatible.  net7.0-windows10.0.19041 net7.0-windows10.0.19041 is compatible.  net8.0-android net8.0-android was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-windows net8.0-windows was computed.  net9.0-android net9.0-android was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-windows net9.0-windows was computed.  net10.0-android net10.0-android was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 446 10/13/2023
1.0.0 309 9/10/2023

Initial Release