it is possible to grab screenshots with tabCapture from a new window opened from a extension?

794 views
Skip to first unread message

cesar pachon

unread,
Mar 2, 2015, 4:24:29 PM3/2/15
to chromium-...@chromium.org
hello, I had been able to capture screenshots within the extension popup, but now I am opening a new window and would like to capture screenshots from the tab that launched the extension (it is a page extension).

first, I tried from the new window, but it fails.

now I am trying from the background page (using a background.html file to hold the canvas and video tags)

but the stream always returns as null or undefined.

I highly appreciate any insights on what is the right approach for this..

thks!

--- manifest ------

  "background" : {
    "page": "background.html",
    "persistent": false
  },

  "page_action" :
  {
    "default_popup": "popup.html"
  },
  "permissions": ["activeTab", "declarativeContent", "tabCapture"],


-----background.html---
<html>
  <head>
  </head>
  <body>
    <video autoplay></video>
    <canvas></canvas>
    <script src="background.js"></script>
  </body>
</html>

---background.js----
   chrome.tabs.getSelected(null, function(tab) {
     //what is the use of tab???
 video = document.querySelector('video');
      canvas = document.querySelector('canvas');
      ctx = canvas.getContext('2d');

      var MediaStreamConstraint = {
            //audio: true,
            video: true,
            videoConstraints: {
                mandatory: {
                    chromeMediaSource: 'tab',
                    minWidth: 640,
                    maxWidth: 800,
                    minHeight: 420,
                    maxHeight: 600
                }
            }
      };

       chrome.tabCapture.capture(MediaStreamConstraint, function(stream){
      console.log(stream); //null or undefined
});

   });



cesar pachon

unread,
Mar 3, 2015, 9:16:13 AM3/3/15
to chromium-...@chromium.org
Reply all
Reply to author
Forward
0 new messages