从项目中的文件夹引用时视频不在 wpf 中播放
Video not playing in wpf when referenced from folder within project
我正在尝试将短视频导入 WPF 应用程序。我在从我的项目中的文件夹中引用视频时遇到问题,所以返回并尝试了本教程。
Creating a complete audio player link
从下面的代码片段中,您可以看到我一直在尝试用什么来替换原始代码。我知道我添加的行会起作用,因为它已在其他地方成功使用。
为什么我无法从我创建的资源文件夹中加载视频但可以加载图像?
确认视频已设置为资源。
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?
因为媒体文件不能是嵌入资源。这是因为 Windows 中的媒体播放器不理解 pack URI:s。该路径必须是相对或绝对系统路径或 URL。
详情请参考以下link
Use DLL resources for WPF MediaPlayer
我正在尝试将短视频导入 WPF 应用程序。我在从我的项目中的文件夹中引用视频时遇到问题,所以返回并尝试了本教程。
Creating a complete audio player link
从下面的代码片段中,您可以看到我一直在尝试用什么来替换原始代码。我知道我添加的行会起作用,因为它已在其他地方成功使用。
为什么我无法从我创建的资源文件夹中加载视频但可以加载图像?
确认视频已设置为资源。
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?
因为媒体文件不能是嵌入资源。这是因为 Windows 中的媒体播放器不理解 pack URI:s。该路径必须是相对或绝对系统路径或 URL。
详情请参考以下link
Use DLL resources for WPF MediaPlayer