Blocking in Javascript

Problem:
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:

OS:

Notes:

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.

Regards,

Thanks a lot Phuong,

your suggestion

    prez.startTimeline("Timeline 1", function (){
        prez.object("PlaybackFinishedMsg").show();
    });

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(){
        prez.object("PlaybackFinishedMsg").show()
        };

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){
        prez.object(Objektname).show()
        };

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){
    prez.object(Objektname).show()
};
1 Like

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