One of the features of the Cheap Ass Gamer app I’ve spent a lot of time on is the podcast controls. 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. To my knowledge, there is no in-built functions for creating an audio progress bar. With help from the internet, this is how I got my progress bar working. I’m of course using Silverlight for Windows Phone in C#.
When you scrub through audio and video, you tap the little dot on the music or video's progress bar and move your finger left or right to rewind or fast-forward (respectively). If you move your.
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. The important thing is they both have these properties: ‘Value’ - the current fill amount of the bar, and ‘Maximum’ - the size of the bar. Make sure the ‘Maximum’ of the progress bar is set before the music starts playing:
Audio Scrub Playerartistic Audio Player And Progress Bar Template
- Audio Scrub Player Widgetic. Starsmall starsmall starsmall starsmall starsmall. Artistic audio player and progress bar.
- I added a buffer progress bar and a second animated progress bar that follows the movement of thumb on the other bar. However, I am only able to scrub the audio of the progress bar with the thumb slider. I did not add click functionality to the animated progress bar. It is for visual purposes only, but is in sync with the movement of the thumb.
- A progress bar is displayed beneath the currently playing thumbnail, and the Scrub-Bar knob also tracks playback progress. Hint: Selection status is independent of which clip is playing. Selected items have a white border in the Playlist pane.
- The hotkey to enable/disable audio while scrubbing is Shift + F.
In order to have the bar keep track of the current position of the music track, a timer will need to be created. When the music starts, create a DispatchTimer and event handlers:
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. After every second the method ’playTimer_Tick’ will be called. This is where we can update the progress bar:
Audio Scrub Playerartistic Audio Player And Progress Barriers
The current time is a Text Block element as you can see in the bottom left of the screenshot. 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. If this happens, I just perform the same assignment without the function.
Audio Scrub Playerartistic Audio Player And Progress Bar Download
And that’s basically it to get the audio progress bar working. If you change track, I suggest having an event to change the Maximum value of the bar to the next track length, like this:
Additionally, you can use the progress bar as a scrub bar so users can change the position of the track themselves…
Audio Scrub Playerartistic Audio Player And Progress Bars
You can use an event for when the user finishes changing the slider value to change the track position like this:
Then, most importantly, in the audio player agent code you need to add this for it to work:
That’s about it. You could use a boolean to stop the progress slider from updating while the user changes the position, but I’ll leave that to you. I hope this has been helpful to someone :)