Xamarin.Forms.VideoPlayer icon indicating copy to clipboard operation
Xamarin.Forms.VideoPlayer copied to clipboard

Local video

Open CarlosEMF2 opened this issue 4 years ago • 3 comments

could you help me?

How to use a local video?

something like that:

            <video: VideoPlayer.Source>
                <video: ResourceVideoSource>
                    <video: ResourceVideoSource.Path>
                        <OnPlatform
                            x: TypeArguments = "x: String"
                            iOS = "Videos / video.mp4"
                            Android = "video.mp4">
                        </ OnPlatform>
                    </video:ResourceVideoSource.Path>
                </ video: ResourceVideoSource>
            </video:VideoPlayer.Source>

CarlosEMF2 avatar Jul 13 '19 13:07 CarlosEMF2

This is how I do it …

In c# ….

Video_Background.Source = VideoSource.FromResource(
                "MobileApp.Images.video.video_sutf_intro.mp4",
                typeof(OwnProfilePage).GetTypeInfo().Assembly);

with the variable set in XAML:

<video:VideoPlayer 
                x:Name="Video_Background"
                AutoPlay="True"
                DisplayControls="False"
                Repeat="True"
                BackgroundColor="Black"
                AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                AbsoluteLayout.LayoutFlags="All"
                Margin="0"
                IsVisible="False"/>

DPY81 avatar Aug 08 '19 13:08 DPY81

Thanks, I will try it

CarlosEMF2 avatar Aug 08 '19 17:08 CarlosEMF2

It works on iOS if you set the relative path of the video file, but not on Android. Currently the only way to play local files with a single codebase is to add your videos as embedded resources on your shared project and set the source as something like the following:

VideoPlayer.Source = VideoSource.FromResource("Videos.particles.mp4");

DanWBR avatar Sep 10 '19 21:09 DanWBR