English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML Audio/video DOM addTextTrack() Method

HTML Audio/Verwendung des video DOM addTextTrack() Methods, Online-Beispiel, wie man HTML Audio verwendet/Detaillierte Informationen zum video DOM addTextTrack() Method, Kompatibilität der Browser, Syntaxdefinition und seine Attributwerte.

 HTML Audio/Video DOM Reference Manual

Online-Beispiel

Eine neue Textspur zum Video hinzufügen:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Audio/Verwendung des addTextTrack() Methods-Grundlegende Anleitung(oldtoolbag.com)</<title>
</<head>
<body>
<button onclick="addNewTextTrack()" type="button">Einen neuen Textspur hinzufügen: </button>
<br> 
<video id="video1" controls="controls">
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Ihre Browser unterstützt keine HTML5 video-Tag.
</video>
<script>
myVid=document.getElementById("video1);
function addNewTextTrack()
{ 
  text1=myVid.addTextTrack("caption");
  text1.addCue(new TextTrackCue("Testtext", 01.000, 04.000,"","","",true));
} 
</script> 
</body>
</html>
Testen Sie es heraus ‹/›

Definition and Usage

The addTextTrack() method creates and returns a new TextTrack object.
A new TextTrack object will be added to the audio/in the list of text tracks of the video element.

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers do not support the addTextTrack() method.

Syntax

audio|video.addTextTrack(kind,label,language)

Parameter

ValuesDescription
kindSpecifies the type of the text track.

Possible values:

  • "subtitles"

  • "caption"

  • "descriptions"

  • "chapters"

  •  "metadata"

labelString value, specifying the label for the text track. Used to identify the text track for the user.
languagetwo-letter language codes, specifying the language of the text track.
For a complete list of available language codes, please refer to our Language Code Reference Manual.

Return Value

TypeDescription
TextTrack ObjectRepresents a new text track.
 HTML Audio/Video DOM Reference Manual