Player callbacks to update progress
Posted: Tue Mar 28, 2023 6:09 am
I’ve been building an app for my own personal use to select and play albums digitized as .mp3 files from my old vinyl collection. These have been organized on disk into subfolders by genre, artist, and actual album. Any one of these files can be located/selected/assigned to the player object via a set of corresponding option menus. This all works works just fine.
However, I’ve hit a brick wall in trying to employ the callback feature of the player to display a graphic that updates periodically as the audiofile plays. Tried first using this feature to update the thumbPosition of a progress scrollbar object. No luck.
Then tried employing a more rudimentary version to update a text field like the examples I’ve found online.
So, for example, the text associated with the first callback might be “>| <”, the second “>|| <”, the third “>||| <”, et cetera. Still no luck.
Here’s the thing: Unlike the examples found online – which were crafted knowing in advance the time at which each callback should be triggered – the duration of each of my album audiofiles is different.
So my strategy has been to identify the duration of the audiofile (the total number of samples, aka intervals), divide that duration by 50 (rounded) to obtain an increment value, then construct a callback list with the first item of each line being a successive multiple of that increment. So no matter the length of the actual audiofile, the handler specified in item 2 of the callback list should be triggered (and the display updated) at each 1/50th of the total duration of the audiofile.
Nope, doesn’t work. (BTW, the timescale of all audiofiles is 44100 samples per second, so it seems unnecessary to employ the adjustments employed in the examples available online. And when I’ve checked the “dontUseQT” property is set to true.)
Frankly, because this app is just for myself, I can live without the graphical update. I just hate to be defeated when trying to master a new LiveCode feature.
Any suggestions would be most welcomed. Thanks!
jeff k
However, I’ve hit a brick wall in trying to employ the callback feature of the player to display a graphic that updates periodically as the audiofile plays. Tried first using this feature to update the thumbPosition of a progress scrollbar object. No luck.
Then tried employing a more rudimentary version to update a text field like the examples I’ve found online.
So, for example, the text associated with the first callback might be “>| <”, the second “>|| <”, the third “>||| <”, et cetera. Still no luck.
Here’s the thing: Unlike the examples found online – which were crafted knowing in advance the time at which each callback should be triggered – the duration of each of my album audiofiles is different.
So my strategy has been to identify the duration of the audiofile (the total number of samples, aka intervals), divide that duration by 50 (rounded) to obtain an increment value, then construct a callback list with the first item of each line being a successive multiple of that increment. So no matter the length of the actual audiofile, the handler specified in item 2 of the callback list should be triggered (and the display updated) at each 1/50th of the total duration of the audiofile.
Nope, doesn’t work. (BTW, the timescale of all audiofiles is 44100 samples per second, so it seems unnecessary to employ the adjustments employed in the examples available online. And when I’ve checked the “dontUseQT” property is set to true.)
Frankly, because this app is just for myself, I can live without the graphical update. I just hate to be defeated when trying to master a new LiveCode feature.
Any suggestions would be most welcomed. Thanks!
jeff k