Using CommunityToolkit.Maui.Camera to implement Video Capture on an Android phone first as a self contained app, then separate video into a class library and finally using that functionality as a NuGet package. NuGet package has been published and the app that uses is available on GitHub. Some issues remain though.

Situation

#### 1. Have created an MAUI Android app that can capture video using the phone’s rear facing camera.

  • Video Preview
  • No audio, no front facing camera option.
  • FPS and Image Stabilization options.
  • Built initially as a self contain app with UI and Video as one project.

#### 2. Modularisation of Video Functionality

  • Object is to encapsulate the Video functionality in a reusable Class Library
  • First step was to partition app into Class library with Video functionality and leave UI in app
    • Implemented by making 2 copies of original app
    • Modify one to just have video functionality as the Class Library
    • Remove video functionality as much as is possible from app, but link to Class Library project

#### 3. NuGet Package version

  • Build and publish class library from 2. as NuGet package.
    • Create new solution including copy of app project from second solution but install NuGet package for video functionality

Outcomes

  1. Works as Debug and Release builds
    • Tested on Google Pixel 6 phone
  2. Debug build works but needs direct link the lib’s built DLL. Method (b) below.
    • Release build fail
  3. Debug build works
    • Release build fails

Linkage of the library

(a) Normal “Add Project Reference” approach

In app project file:

  <ItemGroup>
    <ProjectReference Include="..\..\MauiMediaRecorderVideoSample7a\MauiMediaRecorderVideolib\MauiMediaRecorderVideoLib.csproj" />
  </ItemGroup>

(b) Direct Assembly Reference

In app project file:

  <ItemGroup>
    <!-- Replace project reference with direct assembly reference -->
    <Reference Include="MauiMediaRecorderVideoLib">
      <HintPath>..\MauiMediaRecorderVideolib\bin\Release\net9.0-android\MauiMediaRecorderVideoLib.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>

(c) Nuget Package

In app project file:

	<ItemGroup>
		<PackageReference Include="djaus2_MauiMediaRecorderVideoLib" Version="1.0.2" />
	</ItemGroup>

Achievements thus far.

  • Can get video capture working
  • Can do so for all 3 versions as Debug builds
  • Can get version 1. of the app to run in Release mode.

Remaining Tasks

Overall the main objective is to the NuGet package working with version 3 of the app.

  1. In project 2 get link to class library via that’s project file.
  2. Get Release version of project 2 working with both ways of linking.
  3. Get NuGet package Release build to work.

 TopicSubtopic
<  Prev:   GitHub Copilot v Documentation
   
 This Category Links 
Category:Xamarin Index:Xamarin
<  Prev:   Introduction