In the C# program, I want to display and play a video from within my program in a window.
The path that I give to my video source as an internal path of the embed type works in design mode, but it does not display the video when running the program, but if I give it the direct address of the file in Windows, it works.
This is despite the fact that if I want to show a photo or gif from the same path, it works and shows well
What I need :
In C# WPF on Visual studio 2019 in Windows 10, I want to show and play a video inside a My window from the app not directly path
What have I done :
I have included that video in my project, then I set the path for the video and it shows it to me in design view! :
What have I tried and my code :
so I decided to try it in three-way, also to try to show a gif for sure about the path.
Embedded path
Normal Path
Direct path on windows
but only the direct path works! While the same embedded path works for GIF
MyGIF : Source="pack://application:,,,/Medias/1Correctmation.gif" => works fine
My Video : Source="pack://application:,,,/Medias/Video1.mp4" => not working
My Video : Source="C:\Users\user\Desktop\Video1.mp4" => workis fine but I don't want this directly path
also for my video file I tried these BuildAction:
Embedded
Resource
Content Resource
none of them work.
code from stackoverflow:
https://stackoverflow.com/questions/74423614/how-to-show-an-embedded-video-inside-of-a-window-in-c-sharp-wpf-application[
^]
What I have tried:
What have I tried and my code :
so I decided to try it in three-way, also to try to show a gif for sure about the path.
Embedded path
Normal Path
Direct path on windows
but only the direct path works! While the same embedded path works for GIF
MyGIF : Source="pack://application:,,,/Medias/1Correctmation.gif" => works fine
My Video : Source="pack://application:,,,/Medias/Video1.mp4" => not working
My Video : Source="C:\Users\user\Desktop\Video1.mp4" => workis fine but I don't want this directly path
also for my video file I tried these BuildAction:
Embedded
Resource
Content Resource
none of them work.
<pre> <Grid>
<Label Content="Embeded Video :" HorizontalAlignment="Left" Margin="10,34,0,0" VerticalAlignment="Top" Width="100"/>
<MediaElement x:Name="Embd_Video1_mp4" Margin="115,10,499,309" Stretch="Fill" Source="pack://application:,,,/Medias/Video1.mp4"/>
<Label Content="Normal Path :" HorizontalAlignment="Left" Margin="10,172,0,0" VerticalAlignment="Top" Width="82"/>
<MediaElement x:Name="Normal_Video1_mp4" Margin="115,134,444,154" Stretch="Fill" Source="Medias/Video1.mp4"/>
<Label Content="Direct Path :" HorizontalAlignment="Left" Margin="10,345,0,0" VerticalAlignment="Top" Width="82"/>
<MediaElement x:Name="Dir_Video1_mp4" Margin="115,278,331,10" Stretch="Fill" Source="C:\Users\user\Desktop\Video1.mp4"/>
<Label Content="Embeded Gif Here ↓:" HorizontalAlignment="Left" Margin="452,34,0,0" VerticalAlignment="Top" Width="114"/>
<Image Margin="452,65,30,189" Source="pack://application:,,,/Medias/1Correctmation.gif" />
</Grid>
Source Code : https: