Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force display of subtitles to work around a TV bug #4032

Closed
jeugeneDS opened this issue Aug 24, 2022 · 6 comments
Closed

Force display of subtitles to work around a TV bug #4032

jeugeneDS opened this issue Aug 24, 2022 · 6 comments
Milestone

Comments

@jeugeneDS
Copy link

Hi,
I'm a developer on HbbTV platform.
There is a bug with some HBBTV 2.0 TVs where activating subtitles never works (mode = "showing" does nothing and stays "hidden").
I don't think it comes from Dash.js because if I activate it myself manually it doesn't work either.
The methods dashPlayer.setTextTrack(0); and dashPlayer.enableText(true); do not work either.
It's not related to the stream because I tested a lot of different streams:

Even if the textTrack is hidden the cue.onter and cue.onexit events still work
So as a workaround I had to modify these checks in the event listener cue.onenter (in addCaption()) so that it does not check if the textTrack is indeed active:
if(track.mode === _constants_Constants__WEBPACK_IMPORTED_MODULE_0__["default"].TEXT_SHOWING){

After changing this line, for TTML subtitles it works fine. Dash.js creates the HTML elements, inserts the text into them and the subtitles appear.
But for WebVTT it's not enough, because apparently Dash.js lets the browser manage everything!?

Questions:

  • are there other ways to activate a textTrack because apparently the mode property is sometimes readonly?
  • how to force the library manage the display of WebVTT textTracks as it does for TTML ? I see in the code that Dash.js parses the webVTT
  • Do you know any libraries that could manage the display of these WebVTT ? I tried vtt.js but it breaks Dash.js

The goal for me is that Dash.js always loads, manages and displays the 1st subtitle, even if the browser says it's not enabled

I included my modified dash.js file:
dash.all.debug.zip

Thank for your support

@YannickFuereder
Copy link

Does this example display subtitles on your tv

http://reference.dashif.org/dash.js/latest/samples/captioning/caption_vtt.html

@jeugeneDS
Copy link
Author

Hi @YannickFuereder It's doesn't work. Subtitles not showing.
But I just saw that if I add a textTrack in the video tag it works, subtitles are loaded and displayed:
image

But I have to set the default attribute to true for it to work.
Still doesn't work if I set mode to showing before/after the playback is launched.

@YannickFuereder
Copy link

if the cue events work you could use something like this to display subtitles in a div oncuechange

function changeSubtitle(id) {
  if (lang == -1) {
    video.textTracks[0].mode = "disabled";
    document.getElementById('subtitle').innerHTML = "";
  } else {
    player.setTextTrack(id);
    updateSubs(id);
  }
}

function updateSubs(id) {
  video.textTracks[id].mode = "hidden";

  video.textTracks[id].addEventListener('cuechange', function (e) {
    if (!player.isTextEnabled()) {
      return;
    }

    if (video.textTracks[id].activeCues.length > 0) {
      document.getElementById('subtitle').innerHTML = video.textTracks[id].activeCues[0].text;
    } else {
      document.getElementById('subtitle').innerHTML = "";
    }
  });
}

add this div to your html

<div id="subtitle" class="subtitles"></div>

@YannickFuereder
Copy link

@jeugeneDS feel free to close this issue if it works

@dsilhavy dsilhavy added this to the 4.6.0 milestone Nov 25, 2022
@dsilhavy
Copy link
Collaborator

Implemented custom rendering in #4089

@Murmur
Copy link

Murmur commented Nov 13, 2023

Link to Dashjs slack channel, One of the largest HbbTV manufacturer's device, similar problem having a textTrack.mode=hidden value never switch to showing.
https://dashif.slack.com/archives/C11R69M96/p1699443644118429

If forking a quick debug version track.mode=showing or hidden then ttml subs are visible. Daniel is aware of this problem.

**function _handleHtmlCaption(currentItem, timeOffset, track):
if (track.mode === _constants_Constants__WEBPACK_IMPORTED_MODULE_0__["default"].TEXT_SHOWING
     || track.mode === "hidden") {
        if (this.isd) {
          _renderCaption(this);
          ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants