在特定时间启动和停止 MediaElement
我正在将应用程序更改为 WPF,它根据定时事件播放音频、视频和图片。我使用了 "string MciCommand = string.Format("播放帧从 {0} 到 {1} {2}"" ,之前
我一直在搜索并尝试解决这个问题,现在在 WPF c# 中
- 我有一个视频(wmv)并且我有多个部分需要一起播放。 示例..section1开始(200ms)停止(250ms)section2开始(5000ms)停止(15000ms)
- 最后我需要它在静止帧上暂停..
我尝试使用计时器和空的while循环,但它没有正确寻求。 我很困惑媒体元素似乎不支持这种类型的使用。我想到了 wpfmediakit 和 direct show 很难掌握我的 wpf 新手技能。
任何帮助将不胜感激...
I am change an app over to WPF, it plays audio and video and pictures all based on timed events .. I used "string MciCommand = string.Format("play frames FROM {0} to {1} {2}"" , before.
I have been searching and trying to fix this problem now in WPF c#
- I have a video (wmv) and I have multiple sections that need to be played together.
example .. section1 start(200ms) stop(250ms) section2 start(5000ms) stop(15000ms) - finally I need it to pause on a a still frame ..
I have tried using a timer, and a empty while loop and it doesn't seek properly.
I am at a loss media element doesn't seem to support this type of use. I thought about wpfmediakit and direct show is very hard to wrap my novice wpf skills around.
any help would be greatly appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我最终解决问题的方式。我使用了一个属性列表,并将其用作循环的脚本。如果仓位大于结束时间。它触发计时器并转到列表中的下一个项目..仍然有一些事情可以做得更精致..比如textbox4更改事件也会触发next_item但它完成了工作..现在..
希望这可以帮助遇到同样问题的人...
这是我使用的表单的 Xaml测试....
this was how I ended up solving my problem .. I used a list of properties and used it like a script that I loop through . and if the position in larger than the end time. it trigger the timer and goes to the next item in the list .. there is still some things that could be made a bit more refined .. like the textbox4 changed event also triggers next_item but it gets the job done .. for now ..
Hopefully this helps someone with the same issue ...
here is the Xaml for the form that I used for testing....
嗯,这对我来说太长了,所以我将提供一条对我来说适用于 UWP 项目的路线,该路线看起来简单得多,但不确定它是否适合您的情况:
要跳到正确的位置,请使用 MediaPlayer.PlaybackSession.Position = TimeSpan.FromMilliseconds(yourDesiredPosition);
用于了解何时跳到正确的位置(或执行任何操作)否则你需要启动、停止、切换源等等),只需附加一个位置更改事件:
希望这有帮助......
Hmmm, that was tldnr for me so I'll offer up a route that worked for me for a UWP project that seems much simpler, but not sure if it'll work in your case:
For skipping to the right spots, use MediaPlayer.PlaybackSession.Position = TimeSpan.FromMilliseconds(yourDesiredPosition);
For knowing when to skip to the right spots (or do whatever else you need to, start, stop, switch source, whatever), just attach a position changed event:
hope this helps...