Robert
Robert

Reputation: 19

Maui unable to insert a media element

I have a maui project in VS 2022 and installed the NuGet Community Toolkit Media Element. Problem: I cannot compile the project. Also VS recommends to change the generic to at ".UseMauiApp" but then T is unknown..

MauiProgram.cs:

using CommunityToolkit.Maui;

namespace MotivationByAudio;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<T>()            
            .UseMauiCommunityToolkitMediaElement()
            .ConfigureFonts
            (
                fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                }
            );                  

        return builder.Build();
    }
}

First I started with net6.0 and then changed to net7.0 but it did not help. And net8.0 does not exists for Android VS says..

Upvotes: 0

Views: 112

Answers (1)

Jianwei Sun - MSFT
Jianwei Sun - MSFT

Reputation: 4302

First I started with net6.0 and then changed to net7.0 but it did not help. And net8.0 does not exists for Android VS says..

You can create a brand new project with .NET 8 and remove the code into it. Then install nuget package: CommunityToolkit.Maui.MediaElement

enter image description here

It will no longer have errors appearing. For more information you can refer to the official doc: MediaElement.

Upvotes: 0

Related Questions