Title Song: Up!
Title Artist: Shania Twain
Song Link: https://youtu.be/msizW5q4vE8
Houston, we have a progress bar! This week I was able to finally figure out how to get the progress bar to work correctly and was also able to finish connecting all of the pieces.
It did, however, take quite a few trials and errors to figure out how to get the progress bar working. As mentioned last week, I had been trying to do it based on what percentage of the total length of the line had elapsed, but the math would sometimes get wonky and was overall inconsistent. I also tried using the system time to calculate how much time had passed since the line started, but that also got wonky and wasn’t working correctly. So, I ultimately decided to adjust the SongTimer tick function and make it seem as if the progress bar was moving based on a percentage.
The SongTimer tick function now makes one call to the audioFile.CurrentPosition function and stores it into a TimeSpan that can be used at other points throughout the tick function. By reducing the number of calls to get the current position, there are no missed “ticks” of the timer. Additionally, I changed how I was moving the progress bar with each tick of the timer.
Using the length of line, I calculate how much the progress bar needs to move every half of a second (500 milliseconds, 5 ticks). Then, in the tick function, I keep track of how many ticks have passed and if it has been 5 ticks, then the progress bar value increases by the calculated amount. It doesn’t work quite the way I had hoped for and sometimes reaches the end a little before the lines switch, but ultimately it works quite nicely and I’m happy with the final version.
I’ve included two videos below of the now functioning progress bar. One of them has the value of the progress bar moving every second (1000 milliseconds, 10 ticks) which was my first new solution, and the other has it moving every half second (500 milliseconds, 5 ticks) which was my final solution. I don’t have a video yet going through the entire program, but there will be one soon.
With presentations just over a week away, I’m now focused on creating my presentation, recording demonstration videos as backup, and putting any and all final touches on my project. It has been really nice to finally be able to put everything together and see it working cohesively and I can’t wait to show everyone the finished program.
Well, that’s it for this update. As always, thanks for reading!
Lauren (4/19/22)
Videos:
Sweet Caroline has been stuck in my head so much this past week, I need to start using different songs when I test! Lol
No responses yet