Page 1 of 1

How to show timer for audio tracks?

Posted: Thu Apr 29, 2021 1:35 pm
by IPrem
Hi,

How can I achieve this? Is anybody expert in audio / timers?

GOAL:
- I have a background audio. It starts with a dedicated play button. It plays once.
- I would like to show the time where the audio is currently at. For example --> 1min 37sec
- and of course, this timer should increase as the audio keeps playing

TO CONSIDER
- timer should start / stop when we pause the audio
- timer should start from zero when we click "Re-start Audio" button

NOTE:
- I understand that the timer and the audio may not be 100% in sync due to download latency etc.
- But this is for offline viewing on iPad and there is a dedicated Start Audio button (rather than auto start), so there a great chance that the timer will be 99% in sync with audio.

SHARE (or sell)
If you already build something like this, and you are happy to share (or sell), please let me know!

Thank you!

Re: How to show timer for audio tracks?

Posted: Tue May 18, 2021 4:53 pm
by Hopki
Hi IPrem,
Pano2VR can not do this out of the box however you can use javascript to do this.
Please see the attached project.

It uses a numbered variable in the skin, then a text box that displays the variable using the placeholder $(*mediaTime).
The text box also has a Config Loaded, Go To URL action to trigger the Javascript.

Note the script:

Code: Select all

javascript: setInterval(function() { player.setVariableValue('mediaTime', player.soundGetTime('Element01')); }, 50);

The Pinned Video has the ID of Element01, which you will see in the script 'Element01'.
This makes the link between the video and the time code display.

The text box will display in seconds.
Regards,