//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Namespace WpfApplication1
Public Partial Class Window1
Inherits Window
Private ignoreValueChanged As Boolean = False
Public Sub New()
InitializeComponent()
End Sub
Private Sub MediaOpened(sender As Object, e As EventArgs)
sldPosition.Maximum = meMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds
End Sub
Private Sub Storyboard_Changed(sender As Object, e As EventArgs)
Dim clockGroup As ClockGroup = TryCast(sender, ClockGroup)
Dim mediaClock As MediaClock = TryCast(clockGroup.Children(0), MediaClock)
If mediaClock.CurrentProgress.HasValue Then
ignoreValueChanged = True
sldPosition.Value = meMediaElement.Position.TotalMilliseconds
ignoreValueChanged = False
End If
End Sub
Private Sub sldPosition_ValueChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of Double))
If ignoreValueChanged Then
Return
End If
Storyboard.Seek(Panel, TimeSpan.FromMilliseconds(sldPosition.Value), TimeSeekOrigin.BeginTime)
End Sub
End Class
End Namespace