URL.createObjectURL(stream) has been deprecated

Published: | Categories: Audio & Video, DOM


Firefox and other browsers will soon stop accepting a MediaStream as the object argument for the URL.createObjectURL static method, as the result of discussions among the developers. Firefox 54 will show a deprecation warning in the console when such code is found.

As an example in the spec demonstrates, the HTMLMediaElement.prototype.srcObject property should be used to set a MediaStream on a <video> or <audio> element.

// Don't do this
video.src = URL.createObjectURL(stream);
// Do this
video.srcObject = stream;

Update: The deprecation warning is not displayed on Firefox 54 due to a bug. Firefox 55 and later will show it properly.

Update 2: The stream argument support has been removed with Firefox 62.