TechQA.

video.js "hides" subtitle for firefox? How to show it with a generalized way?

1.1k views Asked by user534498 At 2015-06-23T00:51:55+00:00 23 June 2015 at 00:51 2025-12-25T12:38:39+00:00

I have the following html code:

<div id="video-container" class="container">
<video id="video-player" class="video-js vjs-default-skin" controls
 preload="auto" autoplay width="960" height="540"  crossorigin="anonymous">
  <source src="http://{{$video_server_address}}/file/{{$video_name}}" type='video/mp4' />
  <track label="English" kind="subtitle" srclang="en" src="http://{{$video_server_address}}/file/{{$vtt_name}}" default>
  <p class="vjs-no-js">This video format is not supported.</p>
</video>
</div>

This HTML, without any video.js stuff, will display both videos and subtitles in latest version of FF, chrome and IE without problem.

I then introduce video.js in by the following simple javascript code.

<link href="/js/video-js/video-js.css" rel="stylesheet">
<script src="/js/video-js/video.js"></script>
<script src="/js/jquery-1.11.2.min.js"></script>
<script>
$( document ).ready(function() {
  var player = videojs("video-player");
});
</script>

Then the subtitle is gone for FF. I inspect the video.js created HTML for both FF and chrome, they are different.

For chrome,

<div id="video-container" class="container">
<div crossorigin="anonymous" autoplay="true" preload="auto" class="video-js vjs-default-skin vjs-controls-enabled vjs-has-started vjs-user-inactive vjs-paused vjs-ended" id="video-player" style="width: 960px; height: 540px;">
<video id="video-player_html5_api" class="vjs-tech" preload="auto" autoplay="" crossorigin="anonymous" src="http://127.0.0.1:20001/file/2015/06/23/074043.mp4">
  <source src="http://127.0.0.1:20001/file/2015/06/23/074043.mp4" type="video/mp4">
  <track label="English" kind="subtitle" srclang="en" src="http://127.0.0.1:20001/file/2015/06/23/074043.vtt" default=""></track>
  <p class="vjs-no-js">This video format is not supported.</p>
</video>
==========================================================
===============Ignore many irrelevant stuff here =========
==========================================================
      <div class="vjs-subtitles-button vjs-menu-button vjs-control " role="button" aria-live="polite" tabindex="0" aria-haspopup="true" aria-label="Subtitles Menu">
    <div class="vjs-control-content"><span class="vjs-control-text">Subtitles</span>
      <div class="vjs-menu">
        <ul class="vjs-menu-content">
          <li class="vjs-menu-item" role="button" aria-live="polite" tabindex="0" aria-selected="false">subtitles off</li>
          <li class="vjs-menu-item vjs-selected" role="button" aria-live="polite" tabindex="0" aria-selected="true">English</li>
        </ul>
      </div>
    </div>
  </div> 
</div></div>

And for FF,

<video id="video-player_html5_api" class="vjs-tech" preload="auto" autoplay="" crossorigin="anonymous">
  <source src="http://127.0.0.1:20001/file/2015/06/23/074043.mp4" type="video/mp4">
  <p class="vjs-no-js">This video format is not supported.</p>
</video>
<div aria-label="Subtitles Menu" aria-haspopup="true" tabindex="0" aria-live="polite" role="button" class="vjs-subtitles-button vjs-menu-button vjs-control ">
  <div class="vjs-control-content"><span class="vjs-control-text">Subtitles</span>
    <div class="vjs-menu">
      <ul class="vjs-menu-content">
        <li aria-selected="true" tabindex="0" aria-live="polite" role="button" class="vjs-menu-item vjs-selected">subtitles off</li>
        <li aria-selected="false" tabindex="0" aria-live="polite" role="button" class="vjs-menu-item">English</li>
      </ul>
    </div>
  </div>
</div>

There are two major differences for subtitles, for FF, video.js removed default TRACK tag, this is understandable, because for my testing, FF will not display track subtitle for any dynamically generated video element, so Video.js will try to deal with this by itself? It is ok to me.

The second difference, is for subtitle, you can search for "aria-selected" or "vjs-selected", it is very clear that, for Chrome, the default selection is "English", and for FF, the default selection is "Subtitle Off".

If I manually select English in FF, the subtitle does show.

The problem is then, how can I enable video.js to automatically display the subtitle for FF? I tried to search for video.js API but didn't find any. I used the latest video.js which is 5.0 I think.

javascript html video video.js
Original Q&A
0

There are 0 answers

Related Questions in JAVASCRIPT

  • Using Puppeteer to scrape a public API only when the data changes
  • inline SVG text (js)
  • An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
  • Storing the preferred font-size in localStorage
  • Simple movie API request not showing up in the console log
  • Authenticate Flask rest API
  • Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
  • How to request administrator rights?
  • mp4 embedded videos within github pages website not loading
  • Scrimba tutorial was working, suddenly stopped even trying the default
  • In Datatables, start value resets to 0, when column sorting
  • How do I link two models in mongoose?
  • parameter values only being sent to certain columns in google sheet?
  • Run main several times of wasm in browser
  • Variable inside a Variable, not updating

Related Questions in HTML

  • How to store a date/time in sqlite (or something similar to a date)
  • How to use custom font during html to pdf conversion?
  • Storing the preferred font-size in localStorage
  • mp4 embedded videos within github pages website not loading
  • Scrimba tutorial was working, suddenly stopped even trying the default
  • Is there any way to glow this bulb image like a real light bulb
  • With non-graphical maps in Leaflet, zoomDelta doesn't work
  • What can I do to improve my coding on both html and css
  • Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
  • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
  • Displaying a Movie List on a Website Using Jinja2 and Bootstrap
  • How to redirect to thank you page after submitting a Google form embedded into a Google Site?
  • Storing selected language in localStorage
  • Fences (parenthesis, braces) in HTML and MathML
  • Understanding Scroll Anchoring Behavoir

Related Questions in VIDEO

  • Media player stops about every 5 minutes
  • Video Format is not supported or source is unavailable. - Opera
  • How to get text and other elements to display over the Video in Tkinter?
  • Can I use local resources for mp4 playback?
  • Merge (concat) all video file present in '43. DP (Part1)' and put it into '43. DP (Part1)' and give name merged (concat) file to folder name
  • Google Chrome is consuming a lot of CPU on a video call?
  • How do I automate a video download with Selenium and Python (Meta Quest Store Trailer Download)
  • Safari skipping 5 seconds into react-player video - anyone have experience with this?
  • Why is toDataURL() returning blank image? (with p5 video)
  • How do I circular crop using matlab?
  • Cannot find 'IsacCodec' in scope
  • playing multiple videos with libvlcsharp on multiple monitors
  • Video controls are hidden behind input feature?
  • Anyone around Good at both Javascript and Youtube api?, I am using lite-youtube js and I am confused in adding an eventlistener for onStateChange
  • videos are resizing themselves while scrolling

Related Questions in VIDEO.JS

  • How can I make a video playing with video.js keep playing in the background on iOS?
  • Video.js keeps playing after pausing it (while playing ads via IMA)
  • Audio playback issue with video.js on some browsers - Only one channel playing for multi-channel audio
  • addEventListener with encrypted video-js is not working
  • Challenges with Screen Orientation Changes in Ionic/Capacitor/Angular App Using Video.js
  • How to play different video streams using videoJS in Vuejs
  • How to stop showing two controls in video player
  • How can I replace embedded styles being applied by VideoJS?
  • Implementing HLS Streaming with ClearKey DRM in VideoJS
  • VideoJS Custom DRM
  • How to clear video state when reusing the same video element with videojs-contrib-eme?
  • video.js multiple sources for fairplay widevine playready livestream DRM
  • VideoJS: fetches old segments during a live stream
  • Video JS shows net::ERR_FILE_NOT_FOUND when I change the source but when I played the same video on the home page, it plays
  • How to enable closed captions by default with OpenPlayerJS / video.js?

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)
  • Privacy
  • Terms
  • Cookies
  • Homegardensmart
  • Aftereffectstemplates
  • Jogjafile