MediaManager.Forms UWP, Invalid path error playing local video

0

I'm a beginner to Xamarin.Forms and UWP. I'm trying to play a local *.mp4 file (Assets\Videos\myvideo.mp4) with Plugin.MediaManager.Forms (v1.0.7) > UWP(v6.2.9) project > Xamarin.Forms(v4.8.0.18) solution. but an error occurrs, says "The specified path is invalid. (Exception from HRESULT: 0x800700A1)". would you help me?

*There is no problem with web URLs, just it's for local paths.

I've tried these URLs but none of them works. c#:

Url = "file:///Assets/Videos/myvideo.mp4"
Url = "Assets/Videos/myvideo.mp4"
Url = "ms-appx:///Assets/Videos/myvideo.mp4"

Xml Code:

<mm:VideoView VideoAspect="AspectFit"  Source="{Binding Url}" AutoPlay="True"  ShowControls="True" />

myvideo path at solution explorer:"mysolution\myproject.uwp\Assets\Videos\myvideo.mp4" and build action is "Content".

url
xamarin.forms
uwp
path
visual-studio-2019

1 Answer

0

For Xamarin UWP platform, we suggest you use Xamarin.Forms MediaElement to implement cross-platform media play.

And if you want to play uwp local video file where in the assets folder, you could use the following code.

<MediaElement Source="ms-appx:///XamarinForms101UsingEmbeddedImages.mp4"
          ShowsPlaybackControls="True" />

For more info please refer this part.

answered on Stack Overflow Dec 22, 2020 by Nico Zhu - MSFT

User contributions licensed under CC BY-SA 3.0