w3c / mediacapture-main

Media Capture and Streams specification (aka getUserMedia)
https://w3c.github.io/mediacapture-main/
Other
126 stars 62 forks source link

How can I get from a MediaStreamTrack to its MediaStream parent? #406

Closed dandv closed 8 years ago

dandv commented 8 years ago

I'm building a polyfill for the MediaStream ImageCapture API, and I've run into this issue: in order to create a video element and take a snapshot of it into a canvas, I need access to the MediaStream; however, the ImageCapture constructor only takes a MediaStreamTrack parameter.

How can I get from that track to its parent stream? The track was obtained via getVideoTracks.

alvestrand commented 8 years ago

You can't. A track can be a member of multiple MediaStreams.

You can, however, create a new MediaStream with "new MediaStream(yourTrack)". There's no particular reason to use the original MediaStream, unless you want access to other track inside that MediaStream.

alvestrand commented 8 years ago

Closing as "not a spec issue".

dandv commented 8 years ago

Thanks @alvestrand, passing an array to the constructor worked.