MediaStreamTrack: contentHint property

The contentHint property of the MediaStreamTrack interface is a string that hints at the type of content the track contains. Allowable values depend on the value of the MediaStreamTrack.kind property.

Value

A string with one of the following values:

""

No contentHint has been set.

"speech"

The track should be treated as if it contains speech data. When setting this value, the value of MediaStreamTrack.kind must be "audio".

"speech-recognition"

The track should be treated as if it contains data for the purpose of speech recognition by a machine. When setting this value, the value of MediaStreamTrack.kind must be "audio".

"music"

The track should be treated as if it contains music. When setting this value, the value of MediaStreamTrack.kind must be "audio".

"motion"

The track should be treated as if it contains video where motion is important. For example, webcam video, movies or video games. When setting this value, the value of MediaStreamTrack.kind must be "video".

"detail"

The track should be treated as if video details are extra important. For example, presentations or web pages with text content, painting or line art. When setting this value, the value of MediaStreamTrack.kind must be "video".

"text"

The track should be treated as if video details are extra important, and that significant sharp edges and areas of consistent color can occur frequently. For example, presentations or web pages with text content. When setting this value, the value of MediaStreamTrack.kind must be "video".

Examples

A function that sets the contentHint

This function takes a stream and a contentHint value, and applies the hint to each track. See the full example here, showing how different contentHint values change how the tracks display.

js
function setVideoTrackContentHints(stream, hint) {
  const tracks = stream.getVideoTracks();
  tracks.forEach((track) => {
    if ("contentHint" in track) {
      track.contentHint = hint;
      if (track.contentHint !== hint) {
        console.error(`Invalid video track contentHint: "${hint}"`);
      }
    } else {
      console.error("MediaStreamTrack contentHint attribute not supported");
    }
  });
}

Specifications

Specification
MediaStreamTrack Content Hints
# dom-mediastreamtrack-contenthint

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
contentHint
Chrome – Full support
Chrome 70 (Release date: 2018-10-16)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 57 (Release date: 2018-11-28)
footnote Full support
Safari – Full support
Safari 12.1 (Release date: 2019-03-25)
footnote Full support
Chrome Android – Full support
Chrome Android 70 (Release date: 2018-10-17)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 49 (Release date: 2018-12-07)
footnote Full support
Safari on iOS – Full support
Safari on iOS 12.2 (Release date: 2019-03-25)
footnote Full support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 70 (Release date: 2018-10-17)
footnote Full support
WebView on iOS – Full support
WebView on iOS 12.2 (Release date: 2019-03-25)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support