在 WPF 代码中将 Mediaelement 源设置为相对 URI [英] Set Mediaelement Source to Relative URI in WPF Code

查看:28
本文介绍了在 WPF 代码中将 Mediaelement 源设置为相对 URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目是 WPF4 和 VB.net.我正在尝试使用媒体时间线(在故事板结构内)设置媒体元素的源,以便我可以循环媒体元素.但是,我无法弄清楚如何在 WPF 中将源设置为相对 URI.我知道如何在 VB.net 中执行此操作,但是通过在那里设置源,我无法让媒体循环播放.

I have a project that is WPF4 and VB.net. I'm trying to set a mediaelement's source using a mediatimeline (inside a storyboard construct), so I can loop the mediaelement. However, I cannot figure out how to set the source to a relative URI in WPF. I know how to do it in VB.net, but by setting the source there, I can't have the media looping.

如何将媒体时间线中的媒体元素的来源设置为相对 URI?

How do I set the source of a mediaelement in a mediatimeline to a relative URI?

推荐答案

请参阅 MSDN 参考 MediaElement.Source 属性.确保媒体文件属性Copy To Output"设置为Copy Always"或Copy If Newer".

See the MSDN reference to the MediaElement.Source property. Make sure the media file property "Copy To Output" is set to "Copy Always" or "Copy If Newer".

示例:

<MediaElement x:Name="xyzName" Width="Auto" Height="Auto" Source="MediaFolder/YourMediaFile.mov" />

这篇关于在 WPF 代码中将 Mediaelement 源设置为相对 URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆