'getDisplayMedia needs user gesture to execute

in safari i am having problem to execute getDisplayMeDia because it needs user gesture to call the method. how to surpass this steps. how can i call getDisplayMedia without any gesture in safari


  invokeGetDisplayMedia(success, error) {
    var displaymediastreamconstraints = {
      video: {
        displaySurface: "monitor", // monitor, window, application, browser
        logicalSurface: true,
        cursor: "always", // never, always, motion
      },
    };

    // above constraints are NOT supported YET
    // that's why overridnig them
    // ts
    displaymediastreamconstraints = {
      // @ts-ignore
      video: true,
    };
    // @ts-ignore
    if (navigator.mediaDevices.getDisplayMedia) {
      // @ts-ignore
      navigator.mediaDevices
        // @ts-ignore
        .getDisplayMedia(displaymediastreamconstraints)
        .then(success)
        .catch(error);
    } else {
      // @ts-ignore
      navigator
        // @ts-ignore
        .getDisplayMedia(displaymediastreamconstraints)
        .then(success)
        .catch(error);
    }
  }


Solution 1:[1]

how can i call getDisplayMedia without any gesture in safari

You can't.

It's as simple as that.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brad