When I try to add
<video controls>
<source src="content.mp4" type="video/mp4" />
<source src="content.webm" type="video/webm" />
Your browser does not support the video.
</video>
in my react js project, Eslint throws the following error :-
Media elements such as < audio > and < video > must have a < track > for
captions.
Any idea what is this? And how should I fix this in the best way??
2
Answers
This is my solution. Just give it a try
Based on my understanding of your question, it seems you’re seeking information about adding a subtitles track. You can find details on how to do this here:
MDN Link
To include a subtitles track, you need to modify your tag like this:
If you prefer not to include a subtitles file, you can leave the src attribute empty to avoid the eslint warning.
there.
The error you’re encountering with ESLint is related to the requirement for media elements such as and to have a element for captions. To resolve this issue, you can add an empty element within the tag. Here’s an example of how you can modify your code to include the empty element:
the element is added with the kind attribute set to "captions" to indicate that it is a captions track. The src attribute specifies the URL of the captions file, and srclang specifies the language of the captions. The label attribute provides a label for the captions track, and the default attribute indicates that this track should be the default captions track.
By including the empty element, you address the requirement for media elements to have a captions track, resolving the ESLint error.
Good Luck!