Video won't display in WPF project using Xamarin.Forms

Viewed 110

I'm trying to get video to display in my WPF app, written in C# using Xamarin.Forms. It compiles, but the video doesn't display.

I apologize for my long-winded question. I'm trying to provide as much background and detail as I can.

I don't have a lot of coding experience, but I've been working on a personal project for a few years. I originally wrote a Windows app in C# using .NET Framework. I want to make it available on MacOS and Windows, so I started rewriting it using C#, Xamarin, and .NET 5.0.

Originally, I was asking how to get it working in my app. After a suggestion from ToolMakerSteve, I went back to the MediaElementDemos example, got it working on the Android emulator, then added a WPF project.

While I was trying to learn how to display video, I loaded a mediaelement example here and was able to display video in an Android emulator. I then added in a WPF project according to instructions found here.

I set the WPF project as the startup project. When I tried to run it, it errored out with

 Xamarin.Essentials.NotImplementedInReferenceAssemblyException: 'This
 functionality is not implemented in the portable version of this assembly.     You 
should reference the NuGet package from your main application project in order to 
reference the platform-specific implementation.'

pointing to

await FileAccess.CopyVideoIfNotExists("XamarinForms101UsingEmbeddedImages.mp4");

in the App.Xaml.cs file:

using MediaElementDemos.Helpers;
using Xamarin.Forms;

namespace MediaElementDemos
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
        }

        protected override async void OnStart()
        {
            await FileAccess.CopyVideoIfNotExists("XamarinForms101UsingEmbeddedImages.mp4");
            MainPage = new NavigationPage(new MainPage());
        }

        protected override void OnSleep()
        {
        }

        protected override void OnResume()
        {
        }
    }
}

If I comment out that line

await FileAccess.CopyVideoIfNotExists("XamarinForms101UsingEmbeddedImages.mp4"); 

then the application runs, but no video is displayed, regardless of which menu option I choose.

I'm not sure where to look to solve this problem. I've been stuck on this for a few weeks and have begun going in circles with my google searches.

I am willing to learn and do research, and not just asking for a handout. I just don't know where else to look for answers. Thank you in advance for any help or guidance you can provide.

0 Answers
Related