Set Mediaelement Source to Relative URI in WPF Code

冷暖自知 提交于 2021-02-11 04:59:41

问题


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.

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


回答1:


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".

Example:

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


来源:https://stackoverflow.com/questions/5533990/set-mediaelement-source-to-relative-uri-in-wpf-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!