

It’s nested in a try catch because I found the ‘Remove(8)’ function, which is necessary to remove the miliseconds from the time, can cause a rare exception when the string is less than 8 characters. ProgressBar.Value = ĬurrentTime.Text = current time is a Text Block element as you can see in the bottom left of the screenshot.

Public void playTimer_Tick(object sender, EventArgs e)
Audio bar progress math update#
This is where we can update the progress bar: After every second the method ’playTimer_Tick’ will be called. I chose a second interval for the event to be called, as this is a reasonable time for music and it shouldn’t be too much of a strain on the phone. PlayTimer.Tick += new EventHandler(playTimer_Tick) PlayTimer.Interval = TimeSpan.FromMilliseconds(1000) //one second When the music starts, create a DispatchTimer and event handlers: In order to have the bar keep track of the current position of the music track, a timer will need to be created. Make sure the ‘Maximum’ of the progress bar is set before the music starts playing: The important thing is they both have these properties: ‘Value’ - the current fill amount of the bar, and ‘Maximum’ - the size of the bar. Obviously you’re going to need a progress bar control or if you want to be able to scrub through the song, I suggest the Super Slider from the Coding4Fun Toolkit. I’m of course using Silverlight for Windows Phone in C#.

With help from the internet, this is how I got my progress bar working. To my knowledge, there is no in-built functions for creating an audio progress bar. A progress bar is really useful to the user to instantly get an idea of how long the track is and how far they are in to it. One of the features of the Cheap Ass Gamer app I’ve spent a lot of time on is the podcast controls.
