files/en-us/web/api/mediastreamtrack/contenthint/index.md
{{APIRef("Media Capture and Streams")}}
The contentHint property of the {{domxref("MediaStreamTrack")}} interface is a string that hints at the type of content the track contains. Allowable values depend on the value of the {{domxref("MediaStreamTrack.kind")}} property.
A string with one of the following values:
""
contentHint has been set."speech"
"audio"."speech-recognition"
"audio"."music"
"audio"."motion"
"video"."detail"
"video"."text"
"video".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.
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}}
{{Compat}}