在 MediaElement 中重复视频的最简单方法是什么
我有一个 MediaElement,其中源绑定到一些数据
<MediaElement Source='{Binding Something}' />
重复视频的最简单方法是什么?理想情况下,MediaElement 将具有重复行为属性。
<MediaElement RepeatBehavior='Forever' ... />
但我找不到这样的财产。
I have a MediaElement where the source is bound to some data
<MediaElement Source='{Binding Something}' />
What is the simplest way to have the video repeat? Ideally, MediaElement would have a repeat behavior property.
<MediaElement RepeatBehavior='Forever' ... />
But I can't find such a property.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要将 Storyboard 添加到 MediaElement。请参阅下面的示例:
You need to add a Storyboard to the MediaElement. See the example below:
我通过设置 <代码>UnloadedBehavior 到
MediaState
.Manual
和以下代码:将位置设置为零不起作用...
I made it work by setting the
UnloadedBehavior
toMediaState
.Manual
and the following code:Setting the position to Zero didnt work...
我知道有点晚了,但我无法使用 MSDN 上的示例。因此,经过研究,我找到了这个项目:WPF Media Kit,只需单击浏览屏幕右侧最新版本中的链接。您将输入示例应用程序的代码。我喜欢这个库,因为循环就像:
或
希望这对其他人有帮助。
问候!
I know it's a little late, but I couldn't get to work the example from MSDN. So after research I've found this project: WPF Media Kit, just click at the Browse link in the Latest Version at the right side of the screen. You'll enter the code of the sample application. I liked this library because a loop was as simple as:
or
<DirectShowControls:MediaUriElement x:Name="MyPlayer" Loop="True" />
Hope this helps someone else.
Regards!
将
mediaElement.Position = new TimeSpan(0,0,1)
添加到媒体播放器方法(在播放媒体之前)不会产生任何效果,正如 MasterMastic 和 Guido Zanon 所建议的那样。我使用给定的内容为 MediaEnded 创建了 MediaElement 事件,并且它有效。Adding
mediaElement.Position = new TimeSpan(0,0,1)
to the media player method doesn't (before playing the media) have any effect rather as suggested by MasterMastic and Guido Zanon. I created MediaElement event for MediaEnded with the given content and it worked.