Search code examples
javascriptrecordrtc

How to wait say 5 seconds after user selects the tab|window to record on


I'm using RecordRTC for screen recording on my website.

I want to wait for 5 seconds and show a timer-like thing AFTER THE USER HAS SELECTED THE WINDOW|TAB to record the screen on.

Basically I'm interested on some browser events that will be fired when the user selects the window|tab to perform screen recording on.

Is this possible? Thx in advance.


Solution

  • something like this ?

    const delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
    await delay(5000);
    
    console.log('something'); // will run after 5 seconds
    

    (it has to be inside and async function)