EDIT:
I'm really running out of ideas and solutions. Here are the things I have attempted:
Setting a variable to the stream. Failed because
window.whatever
references the window of the extension!Running a function from a background script and passing the stream to set the variable. Failed because when I tried, I need to put the stream in JSON and that does not work.
Dispatching a Custom Event which holds the stream in its details. Failed because the details suddenly become
null
when I try adding them to the details. It works with normal strings or other stuff of that sort.
I can't figure out how to do anything more than this and this is more difficult than I thought.
How can I construct a MediaStream from another one without passing it directly? For example, if I could do this by using an di, an my id was abcdefghijklmnopqrstuvwxyz0123456789
, then I would be able to get a MediaStream with:
var mystream=MediaStream("abcdefghijklmnopqrstuvwxyz0123456789");
Of course I'm doing something wrong, but how can I construct a MediaStream from an a preexisting MediaStream, without passing that previous one directly?
Explanation:
I have a browser extension. It picks up a MediaStream and now has it stored in a variable. Another page will need that variable so that it can display the live stream on itself. To do this, I will need that MediaSream in that variable. I have already learned that MediaStreams can't be stored in JSON, so I can't just put it in localStorage. How can I pass this MediaStream to the webpage without directly passing it (as that's not possible)?
Constructor
Creates and returns a new MediaStream object. You can create an empty stream, a stream which is based upon an existing stream, or a stream that contains a specified list of tracks (specified as an array of MediaStreamTrack objects).
Bold mine, links from MDN
As seen in the bold, we can create one from a preexisting MediaStream. This does work:
// stream preexists as a MediaStream
var newstream=MediaStream(stream); // makes a new MediaStream with a new id
But I want to stream media from a preexisting MediaStream. How can I pass the MediaStream from the extension to the page?