3

I'm building an extension that one part of it's functionality is recording the screen. after enabling record in the popup interface the background.js creates a mediaStream object successfully. I'm doing in the background script because the background eventually will have to handle the save of this video (send it to a server).

But I also want to have a player to show that video before saving (to confirm or discard it), but when passing a message from the background script to the pop script the media object arrives empty;

this is what the background sends:

isRecording: true
stream: MediaStream
  active: true
  id: "zS8d6Jc7FzJQ5gWXWy9fyHiWquGaOW626FhV"
  onactive: null
  onaddtrack: null
  oninactive: null
  onremovetrack: null
  __proto__: MediaStream
__proto__: Object

and this is what arrives to the popup script:

isRecording: true
 stream: {}
 __proto__: Object
__proto__: Object

To my best understanding it happens because of JSON serialization... How can I overcome it?

Thanks

dor272
  • 550
  • 1
  • 6
  • 26
  • Extension messaging can only send JSON-compatible portion so don't use extension messaging. Share the data directly via chrome.runtime.getBackgroundPage or use the standard DOM messaging like BroadcastChannel. – wOxxOm Apr 15 '20 at 19:17

0 Answers0