-
Notifications
You must be signed in to change notification settings - Fork 45.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add srcObject and mozSrcObject attributes #1474
Conversation
In previous versions of firefox in chrome (pre window.URL) this is how you attached MediaStreams to a video element. ```js el.srcObject = stream; // chrome and opera el.mozSrcObject = stream; // firefox ``` To support those browsers I am proposing that these attributes be added so you can construct a video element like so: ```js // chrome React.DOM.video({ srcObject: stream }); // firefox React.DOM.video({ mozSrcObject: stream }); ``` (CLA signed)
Currently I have my own Video tag abstraction to handle this cross-browser stuff, is this something you would be interested in having in core? I noticed that there are built-in abstractions over some elements. The ideal usage would be simply: React.DOM.video({
stream: stream
}); which would internally do the dance between URL.createObjectURL, srcObject, and mozSrcObject that is basically (pseudo-code) if (props.stream) {
if (hasURL) {
// new chrome
props.src = URL.createObjectURL(props.stream);
} else {
// old chrome, ff, opera, ie, etc.
props.srcObject = props.stream;
props.mozSrcObject = props.stream;
}
} and release the object URL on unmount |
As for your second comment, seems reasonable on the surface, React tries to hide inconsistencies where possible (given a reasonable size/benefit ratio). However, if If it requires shimming As for the PR itself, if it can't reasonably resolved by React then simply exposing those attributes seems reasonable. Kind of related, but only mentioning for the sake of awareness #1449. |
@syranide The standard is still in flux right now, it's unclear to me if the future is URL.createObjectURL or the .srcObject attribute. If you don't have WebRTC at all (no URL, no .srcObject) then the stream attribute would not do anything. |
@contra True, but looking at http://www.w3.org/TR/html5/embedded-content-0.html#the-video-element, it makes no mention of |
Does react conform to the spec or to the real world implementations? If to the spec, I'll probably have to close this and fork react. If implementation, then this should be merged. The messaging is slightly confusing because vendor prefixes are available in other parts of the system. |
@contra I'm no official opinion on this, but my interpretation is that React does explicitly normalize behavior, polyfill features and resolve inconsistencies as long as it is consistent with a standard and falls strictly inside of React's namespace (i.e, we don't mess with the expected behavior outside of React) when there's also a reasonable relationship of benefit and size/scope. See; the normalized and polyfilled If I would word it myself, it makes sense to push people in the direction of newer standards when possible, allowing you to code in React as if they were already adopted by all (capable) browsers (see; So it seems to me that if Again, I'm no official opinion on this but it's my honest interpretation of my experience, as I know the "official devs" have been very busy the last few weeks. So they may not be able to reply to everyone in a timely manner. |
@syranide Yep that path sounds good to me |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
ping @zpao, want to take this? |
Closing in favor of a new (and broader) PR |
Hmm -this is really old. srcObject is standard these days: https://html.spec.whatwg.org/multipage/embedded-content.html#media-elements and implemented by major browsers, it is also more convenient than the objectURL approach, which requires manual resource cleanup. Can we allow srcObject in react? |
same problem here. https://www.fxsitecompat.com/en-CA/docs/2017/url-createobjecturl-stream-has-been-deprecated/ |
In previous versions of firefox in chrome (pre window.URL) this is how you attached MediaStreams to a video element.
To support those browsers I am proposing that these attributes be added so you can construct a video element like so:
(CLA signed)