Hi All,
Just trying to implement a basic music player with a progress bar.
I'm updating the progress bar using a timer/storyboard, checking the mediaelement progress. My problem is, when the storyboard is active, the music doesn't playback properly, as if it is cutting out when every time the timer fires. This is my vb code. TIA
Dim sb As Storyboard
Private Sub btnPlayPause_MouseLeftButtonUp(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If MusicFile.CurrentState <> MediaElementState.Playing Then
MusicFile.Play()
sb = New Storyboard
sb.Duration = TimeSpan.FromMilliseconds(100)
AddHandler sb.Completed, AddressOf Timer_Tick
sb.Begin()
ElseIf MusicFile.CurrentState = MediaElementState.Playing Then
MusicFile.Pause()
sb.Stop()
sb = Nothing
End If
End Sub
Private Sub Timer_Tick()
MusicPos.Value = MusicFile.Position.TotalSeconds
sb.Begin()
End Sub