Skip to main content

MAUI projects

Products: Video Capture SDK .Net, Video Edit SDK .Net, Media Player SDK .Net, Media Blocks SDK .Net

VisioForge.Core.UI.MAUI package contains UI controls for the .Net MAUI platform.

Initializing

To use the .NET MAUI VisioForge SDKs, you need to call the extension method in your MauiProgram.cs file as follows:

using SkiaSharp.Views.Maui.Controls.Hosting;
using VisioForge.Core.UI.MAUI;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
// Initialize the SkiaSharp package by adding the below line of code
.UseSkiaSharp()
// Initialize the VisioForge MAUI package by adding the below line of code
.ConfigureMauiHandlers(handlers => handlers.AddVisioForgeHandlers())
// After initializing the VisioForge MAUI package, optionally add additional fonts
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

// Continue initializing your .NET MAUI App here
return builder.Build();
}
}

XAML usage

To make use of the SDK within XAML, you can use this namespace:

xmlns:vf="clr-namespace:VisioForge.Core.UI.MAUI;assembly=VisioForge.Core.UI.MAUI"

Add the VideoView to the Activity or Fragment layout:

<vf:VideoView Grid.Row="0"               
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
x:Name="videoView"
Background="Black"/>

Android additional steps

Add the custom Java Bindings Library

You need to add the custom Java Bindings Library to your project for correct work on Android.

  1. Clone the binding library folder from GitHub.
  2. Add the VisioForge.Core.Android.X7.csproj (net7) or VisioForge.Core.Android.X8.csproj (net8) to your solution.
  3. Add the helper library dependency to your project csproj file (only for Android target). Replace the path to the library if needed.
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<ProjectReference Include="..\..\..\AndroidDependency\VisioForge.Core.Android.X7.csproj" />
</ItemGroup>

Add Android redist

You need to add the Android redist package to your project for correct work on Android.

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<PackageReference Include="VisioForge.CrossPlatform.Core.Android" Version="1.22.5.10" />
</ItemGroup>

MacOS additional steps

You need to specify runtime identifiers for your project correctly. For example, if you want to build your project for x64 and arm64 architectures, you need to add the following lines to your project file:

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('osx')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64' AND $(TargetFramework.Contains('-maccatalyst'))">
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('osx')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64' AND $(TargetFramework.Contains('-maccatalyst'))">
<RuntimeIdentifier>maccatalyst-arm64</RuntimeIdentifier>
</PropertyGroup>

PublishTrimmed option should be enabled for macOS.

<PublishTrimmed Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">true</PublishTrimmed>

Check the macOS page for more information about deployment.

iOS additional steps

Add iOS redist

You need to add the iOS redist package to your project for correct work on iOS.

<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
<PackageReference Include="VisioForge.CrossPlatform.Core.iOS" Version="1.23.0" />
</ItemGroup>

No additional steps are required.

Use the physical device target, not the simulator.

Windows additional steps

Add Windows redist

You need to add the Windows redist package to your project for correct work on Windows.

Add base redist and codecs redists.

<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<PackageReference Include="VisioForge.CrossPlatform.Codecs.Windows.x64" Version="15.7.0" />
<PackageReference Include="VisioForge.CrossPlatform.Core.Windows.x64" Version="15.7.0" />
</ItemGroup>

Add libAV (FFMPEG) redist that contains additional codecs and format support.

<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<PackageReference Include="VisioForge.CrossPlatform.Libav.Windows.x64" Version="15.7.0" />
</ItemGroup>

Visit our GitHub page to get more code samples.