Page view counter
Music Playback v.choppy when timer is active (Silverlight 2) Subscribe to this thread
Last post 11-16-2008 10:47 AM by enrico1982. 4 replies.
Sort Posts:
11-13-2008 6:04 PM
Music Playback v.choppy when timer is active (Silverlight 2)

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
  
enrico1982

Loading...
Joined on 11-13-2008
Posts 3
11-14-2008 12:28 AM
Re: Music Playback v.choppy when timer is active (Silverlight 2)

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?

Please "Mark as Answer" if any of my content helped
Bart Czernicki
http://www.silverlighthack.com | http://www.twitter.com/bartczernicki

bartczernicki

Loading...
Joined on 04-30-2008
New Jersey, USA
Posts 636
11-15-2008 12:18 PM
Re: Re: Music Playback v.choppy when timer is active (Silverlight 2)

 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

enrico1982

Loading...
Joined on 11-13-2008
Posts 3
11-15-2008 1:02 PM
Re: Re: Music Playback v.choppy when timer is active (Silverlight 2)

 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?

Please "Mark as Answer" if any of my content helped
Bart Czernicki
http://www.silverlighthack.com | http://www.twitter.com/bartczernicki

bartczernicki

Loading...
Joined on 04-30-2008
New Jersey, USA
Posts 636
11-16-2008 10:47 AM
Re: Re: Music Playback v.choppy when timer is active (Silverlight 2)

 I tried MusicFile.play after setting up and starting  the storyboard. Still the same problem.

The file is an mp3.

Thanks.
enrico1982

Loading...
Joined on 11-13-2008
Posts 3
Microsoft Communities