This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The srcObject property of the HTMLMediaElement interface sets or returns the object which serves as the source of the media associated with the HTMLMediaElement. The object can be a MediaStream, a MediaSource, a Blob and a File (which inherits from Blob).

As of November 2017, browsers only support MediaStream. For MediaSource, Blob and File, you have to create a URL with URL.createObjectURL() and assign it to HTMLMediaElement.src. See below for an example.


var mediaStream = HTMLMediaElement.srcObject
HTMLMediaElement.srcObject = mediaStream


MediaStreamMediaSource, Blob, or File object (though see the compatibility table for what is actually supported).


This example uses srcObject and gracefully falls back to src if srcObject throws an error.

const mediaSource = new MediaSource();
const video = document.createElement('video');
try {
  video.srcObject = mediaSource;
} catch (error) {
  video.src = URL.createObjectURL(mediaSource);


Specification Status Comment
HTML Living Standard
The definition of 'srcObject' in that specification.
Living Standard Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 52.0[1] 18.0 (18.0)[1][2]
42.0 (42.0)[1]
? 39[1] 11
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 52.0 ? ? ? 39 11 52.0

[1] Only MediaStream objects are currently supported. MediaSource, Blob and File objects are yet to be supported, and throw a TypeError. See the tracking bugs for MediaSource support in Chrome (bug 506273) and Firefox (bug 886194).

[2] Early versions of Firefox implemented this under the non-standard name mozSrcObject. This non-standard property was removed in Firefox 58 (bug 1183495).

Document Tags and Contributors

 Last updated by: Jedipedia,