Skip to main content
Home Forums Silverlight Design Video and Media Music Playback v.choppy when timer is active (Silverlight 2)
4 replies. Latest Post by enrico1982 on November 16, 2008.
(0)
enrico1982
Member
0 points
3 Posts
11-13-2008 6:04 PM |
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
bartczer...
Contributor
3838 points
666 Posts
11-14-2008 12:28 AM |
Try lowering the MaxFrameRate setting in Silverlight to 30. The default is 60, this will make StoryBoards fire less events and consume less time in the main UI thread. This setting is set on the Silverlight control object.
Also are you doing Windowless="false" or any HTML overlay with Silverlight?
11-15-2008 12:18 PM |
Hi, Thanks for the reply.
Set MaxFrameRate to 30, makes no difference.
No i'm not doing windowless="false" or have a html overlay
Any other ideas.
Thanks
11-15-2008 1:02 PM |
I will try the code out a little later, I think I moving the StoryBoard lines before the musicfile starts might be a good idea. Is this just a simple mp3 or wmv you are playing?
11-16-2008 10:47 AM |
I tried MusicFile.play after setting up and starting the storyboard. Still the same problem.
The file is an mp3.