Blocking in Javascript

Hi, is there a way to play an audio through JS and have the code stop while its doing that? Similarly to the ‘blocking’ checkbox in the AP UI?

Thanks, Rolf

ActivePresenter version:



Hi Rolf,

Please check the attached sample to see if it is what you are looking for:
Audio.approj (852 KB)
I use an interactive timeline to control playback of the audio, then add a script to start the timeline with a callback.


Thanks a lot Phuong,

your suggestion

    prez.startTimeline("Timeline 1", function (){

works fine. I would like to just have the name of the function as callback and not the whole function.

So, I tried

    prez.startTimeline("Timeline 1", Message);
    function Message(){

which works fine, too!

However, I would like to pass the name of the object with the callback, i.e.

    prez.startTimeline("Timeline 1", Message("PlaybackFinishedMsg");  
    function Message(Objektname){

Is that possible as well? I don’t get it to work …

Thanks, Rolf

Hi Rolf,

The first line of the code is missing a closing parenthesis. However, by passing a parameter, the callback will be executed immediately which leads to unexpected result.
You can try the following:

prez.startTimeline("Timeline 1", function () { Message("PlaybackFinishedMsg") } );  
function Message(Objektname){
1 Like

Hi, excellent! Exactly what I needed!
Thanks, Rolf