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

The text track setting saved to local storage and read by the MediaController during initialization are not taken into account by the TextController/TextTrack. #4164

Closed
4 tasks done
HugoSaintLaurent opened this issue Mar 30, 2023 · 3 comments
Labels
Milestone

Comments

@HugoSaintLaurent
Copy link

Environment
Steps to reproduce

Play a stream with multiple text tracks like https://storage.googleapis.com/shaka-demo-assets/sintel/dash.mpd for example.
Change to a different text tracks, leaving the video, retune, and verify if the text track matches the setting in the options menu.

Observed behavior

The text track setting are saved to local storage (https://github.sie.sony.com/SIE-Private/dashjs/blob/master/src/streaming/controllers/MediaController.js#L210).
And they are read by the MediaController during initialization (https://github.sie.sony.com/SIE-Private/dashjs/blob/master/src/streaming/controllers/MediaController.js#L69).
However, the TextController/TextTrack does not take into account these setting, and instead sets the default text track as the current one (https://github.sie.sony.com/SIE-Private/dashjs/blob/master/src/streaming/text/TextTracks.js#L161).

Turning off the closed captions is not remembered either. I'm not sure if this is expected or not.

This issue appears to be related to #1866

Console output

Sorry, I don't have log at the moment.

Expected behavior

After changing different text tracks, leaving the video, retuning, the text trackshould matches the setting in the options menu.

Possible solution

The following fix resolves the issue, however there might be a better way to fix this.

Modify https://github.sie.sony.com/SIE-Private/dashjs/blob/master/src/streaming/text/TextController.js#L128 as follow:
function createTracks(streamInfo) {
const streamId = streamInfo.id;

    if (!textTracks[streamId]) {
        return;
    }
    textTracks[streamId].createTracks();

    // Fix start
    // The Media Controller loads the initial text track saved in local storage,
    // but the Text Track doesn't.  Check to see if they're different and then
    // try and set the correct text track index.
    const textTrack = textTracks[streamId].getCurrentTrackInfo();
    const mediaTrack = mediaController.getCurrentTrackFor(textTrack.type, streamId);
    if (textTrack && mediaTrack && textTrack.index !== mediaTrack.index) {
        setTextTrack(streamId, mediaTrack.index - textTrack.index);
    }
    // Fix end

The unit tests have the same results with and without this change.

@HugoSaintLaurent HugoSaintLaurent changed the title The text track setting are saved to local storage and read by the MediaController during initialization are taken into ccount by the TextController/TextTrack. The text track setting saved to local storage and read by the MediaController during initialization are not taken into account by the TextController/TextTrack. Mar 30, 2023
@dsilhavy dsilhavy added this to the 4.7.1 milestone Apr 25, 2023
@dsilhavy
Copy link
Collaborator

dsilhavy commented Jun 6, 2023

@HugoSaintLaurent Can you please recheck in 4.7.0: https://reference.dashif.org/dash.js/v4.7.0/samples/dash-if-reference-player/index.html I was not able to reproduce the problem, reloading the media results in using the last selected track.

getCurrentTrack is called in _onTextTracksAdded

@dsilhavy
Copy link
Collaborator

Closing for now as this seems to work. Please comment if you see any remaining issues.

@HugoSaintLaurent
Copy link
Author

Hi @dsilhavy, I finally had I chance to double check this issue. And it looks fixed on my end to with 4.7.0.
Best regards

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

No branches or pull requests

2 participants