adamfisher/Xamarin.Forms.VideoPlayer

Local video

Opened this issue · 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>
DPY81 commented

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"/>

Thanks, I will try it

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");