我需要播放一部分Mediaelement,例如从第二个0:45到0:55秒
我尝试使用mediaelement position属性这里是代码
Dim mytimeline As New MediaTimeline
Dim mc As MediaClock
FReveal1.Visibility = Windows.Visibility.Visible
FReveal1.Source = New Uri("videos\Front-Game-Answer-Reveals.wmv", UriKind.Relative)
FReveal1.Position = New TimeSpan(0, 0, 4)
mytimeline.Source = FReveal1.Source
mytimeline.Duration = (TimeSpan.FromMilliseconds(5000))
mc = myTimeLine.CreateClock()
FReveal1.Clock = mc
FReveal1.Play()
但是我收到以下错误:“将时钟分配给媒体播放器时无法执行此操作。”
还有其他办法吗?
由于
答案 0 :(得分:1)
这样的事情会起作用吗?
var StartTime = new TimeSpan(0, 0, 45);
var EndTime = new TimeSpan(0, 0, 55);
theMediaElement.Position = StartTime;
theMediaElement.Play();
while (theMediaElement.Position != EndTime)
{
// chill and let it play
}
theMediaElement.Stop();
编辑:我应该补充一点,这有点像牛仔。