Is there a way to check when a set mediaelement position is reached?
When I set the position in a mediaelement is there any event or thing to check to see when it has开发者_运维知识库 reached that position?
I have tried to check for buffering as I figured it would do that but no. I have also tried get the position but that one of cause returns what I just set even though the seek is not yet done.You can check (MediaElement.Position Property) http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.position.aspx
Unfortunately, there is no event to support that. If your aim is to play the file from x position to y position, you can use MediaTimeline, create a clock from it and add the clock to MediaElement. If however, you need to synchronise something with your playback, the only option is to use a timer to check for position again and again.
I'm using:
private async void videoElement_SeekCompleted(object sender, RoutedEventArgs e)
That seems to fire once the position has changed, and the video has been rendered.
For those that came looking for MediaPlayerElement
instead of MediaElement (as Microsoft's docs recommend using), you can do this by subscribing to:
someMediaPlayerElement.MediaPlayer.PlaybackSession.PositionChanged;
Then, in the handler, check sender.Position
for the new position.
精彩评论