'How to record a particular tab stream using getUserMedia

I want to record a particular tab (by specifying the tab id) without showing the tab selection dialog from getUserMedia. For this I use mediaSource as browser and a tabId as described in https://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints

navigator.mediaDevices
    .getUserMedia({
      video: {
        mediaSource: 'browser'
      },
      tabId: <my_tab_id>
    })

But this always records a particular tab on its own, irrespective of what tab id I specified. How can I make this work on my selected tabId?

Fiddle - https://jsfiddle.net/58rL3psg/



Sources

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

Source: Stack Overflow

Solution Source