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

Default flag not working on tracks (subtitles, captions) #656

Closed
engamaraziz opened this issue Jul 26, 2013 · 7 comments
Closed

Default flag not working on tracks (subtitles, captions) #656

engamaraziz opened this issue Jul 26, 2013 · 7 comments

Comments

@engamaraziz
Copy link

The default subtitles are not showing when the video is played. However, it works correctly when choosing it form the menu.

Here's my code:

<video id="intro" class="video-js vjs-default-skin" controls
                                   preload="auto" width="500" height="300" poster="xxx.png"
                                   data-setup="{}">
                                <source src="xxx.mp4" type='video/mp4'>
                                <source src="xxx.webm" type='video/webm'>

                                <track kind="subtitles" src="xxx.vtt" srclang="fr" label="French" default>
</video>

Is it a bug or I am doing something wrong?

Upon Googling the issue I found some people are facing the same issue.

Please help.

@heff
Copy link
Member

heff commented Jul 29, 2013

It looks like there's a partial implementation that could be un-commented. Needs to be tested.
https://github.com/videojs/video.js/blob/v4.1.0/src/js/tracks.js#L60

@sikoried
Copy link

sikoried commented Oct 3, 2013

A fix of that bug (or a public function to enable the track via js) would be greatly appreciated! Thanks!

@smoreau
Copy link

smoreau commented Oct 23, 2013

+1

@salmazov
Copy link

No! No! And no! It's impossible! I uncomment this code, heff and...

123

@Korotkiewicz
Copy link

I solved this problem by modifying method vjs.TextTrackMenuItem (line: 6666):

vjs.TextTrackMenuItem = vjs.MenuItem.extend({
  /** @constructor */
  init: function(player, options){
    var track = this.track = options['track'];

    // Modify options for parent MenuItem class's init.
    options['label'] = track.label();
    options['selected'] = track.dflt();
    vjs.MenuItem.call(this, player, options);

    this.player_.on(track.kind() + 'trackchange', vjs.bind(this, this.update));
    /**
    * @author Michal Korotkiewicz
    * my modification:
    */
    if(track.dflt()) {
        this.player_.showTextTrack(this.track.id_, this.track.kind());
    }
  }
});

@akitrav
Copy link

akitrav commented Jan 14, 2014

@Korotkiewicz thanks a lot it worked for me...

@Chris-DL
Copy link
Contributor

Thanks @Korotkiewicz, for tracking this down and posting a workable solution to the issue. However, I did not see a pull request for the fix, so I took a second look and found that it was failing one of the unit tests. I tracked this down to the player.js test where it checks the validity of the player and associated tracks. I believe the test failed because (with the newly added fix) there is no external file to pull the content from on default, hence the failure. Adding an additional check to see if the video was set to auto preload is one possible solution.

this.player_.on(track.kind() + 'trackchange', vjs.bind(this, this.update));

/**
* Add additional check parameter for auto preload
*/
var preload = player.options_['preload'];
if(track.dflt() && preload === 'auto') {
    this.player_.showTextTrack(this.track.id_, this.track.kind());
}

Chris-DL added a commit to Chris-DL/video.js that referenced this issue Apr 16, 2014
…n tracks (subtitles, captions)"

Added additional check to look for auto preload option to avoid loading external captions, subtitles, etc. file on default
Chris-DL added a commit to Chris-DL/video.js that referenced this issue Apr 17, 2014
…orking on tracks (subtitles, captions)""

This reverts commit 8735935.
@heff heff closed this as completed in 1df28ff May 7, 2014
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants