I'm trying to import short videos into a WPF application. I was having trouble with referencing video from a folder within my project so went back and tried this tutorial.
Creating a complete audio player link
From the snippet below you can see what I have been trying to replace the original code with. I know the line I added will work as it's used elsewhere successfully.
Why can't I load a video from a Resource folder I created but I can load images?
To confirm the video is set to a resource.
private void Open_Executed(object sender, ExecutedRoutedEventArgs e)
{
//OpenFileDialog openFileDialog = new OpenFileDialog();
//openFileDialog.Filter = "Media files (*.mp3;*.mpg;*.mpeg)|*.mp3;*.mpg;*.mpeg|All files (*.*)|*.*";
//if (openFileDialog.ShowDialog() == true)
//mePlayer.Source = new Uri(openFileDialog.FileName);
mePlayer.Source = new Uri("pack://application:,,,/videotest;component/Resource/testvideo.mpeg");
}
Why can't I load a video from a Resource folder I created but I can load images?
Because media files can't be embedded resources. This is because the media player in Windows doesn't understand pack URI:s. The path must be a relative or absolute system path or an URL.
Please refer to the following link for more information.