How to enable picture in picture on a tab change

Instead of the user manually pressing the PiP button is it possible to automatically turn on Picture In Picture when they switch tabs instead with Prebuilt


Best Answer

  • marco
    marco Moderator, Dailynista admin
    Answer ✓

    Hi @reeceatkinson — It's possible to detect whether or not a tab/window is active, so I think what's missing today from daily-js to be able to achieve that behavior would be a method to trigger PiP. Right now, it can only be triggered via the button in Daily Prebuilt.

    I'll submit this as a feature request!


  • Thanks @marco

  • Coming back to this from a recent GitHub issue:

    This will likely not work as you intend it to, because the Picture-in-Picture browser API requires execution from a user gesture (e.g. a button click). Otherwise it throws an error:

    DOMException: Failed to execute 'requestPictureInPicture' on 'HTMLVideoElement': Must be handling a user gesture if there isn't already an element in Picture-in-Picture.