Video.js: Possible to style tracks/caption text?

Created on 6 Dec 2014  路  6Comments  路  Source: videojs/video.js

Very basic question here about video.js functionality-- is it possible to style the tracks-- i.e. subtitle/caption text-- with CSS? I've been searching for a library to assist in this manner, as it seems native support for styling <track> text is rather limited. I'm basically hoping to create a simple bar that spans the width of the video, with a semi-transparent white background that contains the caption text with some padding. Is this possible to achieve with video.js or any other library out there?

Thanks for any guidance here.

question

Most helpful comment

Hi Nick!
This is possible on the Video.JS HTML5 player, but not in the Flash tech. Given below are the classes you can customize (this is just an example styling, you can use your own). You can either modify the "video-js.less" file and compile it to generate the CSS or write your customizations separately after including the video-js.css or video-js.min.css

.video-js .vjs-captions {
  color: #FFFFFF;
  font-family: 'tahoma';
  font-size: 16px;
}

.video-js .vjs-text-track {
  background-color: transparent;
}

All 6 comments

Hi Nick!
This is possible on the Video.JS HTML5 player, but not in the Flash tech. Given below are the classes you can customize (this is just an example styling, you can use your own). You can either modify the "video-js.less" file and compile it to generate the CSS or write your customizations separately after including the video-js.css or video-js.min.css

.video-js .vjs-captions {
  color: #FFFFFF;
  font-family: 'tahoma';
  font-size: 16px;
}

.video-js .vjs-text-track {
  background-color: transparent;
}

Just be warned that videojs is changing the way it's doing captions, so, what @EmperorRXF said won't apply once that lands.
See #1655 for the work that needs to happen.

Thanks for the help @EmperorRXF! What happens when you use that with the Flash tech? It should work there too.

Thanks @EmperorRXF-- do you know by chance if padding is supported in the CSS track customizations?

@gkatsev Thanks for the heads up!
@heff I think I got video.js player mixed up with another player. I'm having difficulty using the flash tech for the player and unable to verify if the styles are picked up. But I'm sure it's working well!

@nickpish if you mean CSS padding, yes any valid CSS is supported!

@EmperorRXF -- fantastic, thanks; I've been looking high and low for this functionality...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

askaliuk picture askaliuk  路  3Comments

kocoten1992 picture kocoten1992  路  4Comments

gfviegas picture gfviegas  路  3Comments

jeonghwaYoo picture jeonghwaYoo  路  3Comments

onigetoc picture onigetoc  路  4Comments