I have a C# .Net 5 WPF application where I'm trying to play an MP4 video as the background of a UserControl. When I set the Source property of a MediaElement to
<MediaElement Source="pack://siteoforigin:,,,/Media/home_background.mp4"... and run the application in the debugger, the video plays without any issues.
However, when I publish the application as a self-contained single-file executable using ClickOnce, the video fails to play, even though it's contained within the .exe file. Upon inspecting the contents of the .exe file with an unarchiver, I was able to identify the pack which included the video file and in a separate video player it plays just fine.
Publishing without choosing "produce single-file" results in a lot of files and a functional video playback.
I've tried setting the properties of the video to different settings, especially "Content" for build action and "Always copy", but this hasn't resolved the issue. I suspect that I'm not referencing the video correctly within the application, but I'm not sure how to fix this.
How can I properly reference the video file so that the MediaElement can still play it even after it was published?