0

I'm making a HTML5 Video Player with number of different languages subtitles. I want to show my subtitles through the VTTCue method only. So far my VTTCue works for English perfectly, but it doesn't work with other languages like hindi, urdu, chinese, japanese, korean and even Spanish. It does not show some of the character of Spanish language such as ó or á. Instead it shows something very different. Please help me. And I only want to show the subtitles through the VTTCue method only. Thanks

My Code:

<html>
<head>
  <title></title>
</head>
<body>
  <video width="640" height="360" src="video.mp4" controls></video>
  <script>
    var video_player = document.querySelector('video');
    var track = undefined;
    track = video_player.addTextTrack("subtitles", undefined, "es");
    track.mode = "showing";
    track.addCue(new VTTCue(0, 10, "cómo están"));
  </script>
</body>
</html>
Kunj
  • 1,980
  • 2
  • 22
  • 34
aman
  • 307
  • 21
  • 48

1 Answers1

0

I suspect you need to set your charset.

A charset defines what characters can be used. While standard English characters are generally safe, characters from other languages can easily be unrecognizable by the default charset.

According to this post, the UTF-8 charset should be used for multilingual content.

According to W3Schools, you can use this to set your charset in HTML4 Standard:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

You can also use this for HTML5 Standard:

<meta charset="UTF-8"> 

These lines would go inside the page's head tag.

Tyler
  • 957
  • 11
  • 27