How to Play a section of the WPFmediaElement
I need to play a section of the Mediaelement for example from the second 0:45 to 0:55 sec
I tried using the mediaelement position property here is the code
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.P开发者_如何转开发osition = New TimeSpan(0, 0, 4)
mytimeline.Source = FReveal1.Source
mytimeline.Duration = (TimeSpan.FromMilliseconds(5000))
mc = myTimeLine.CreateClock()
FReveal1.Clock = mc
FReveal1.Play()
But I get the following error : "Cannot perform this operation while a clock is assigned to the media player."
Is there another way to do this ?
Thanks
Would something like this work?
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();
EDIT: I should probably add that this is a bit cowboy.
精彩评论