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

Captions fixes #609

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/demo-files/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
<track kind="captions" src="demo.captions.vtt" srclang="en" label="English" />
<track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
</video>

</body>
Expand Down
1 change: 1 addition & 0 deletions sandbox/index.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4'>
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm'>
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg'>
<track kind="captions" src="../build/demo-files/demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
<p>Video Playback Not Supported</p>
</video>

Expand Down
15 changes: 1 addition & 14 deletions src/css/video-js.css
Original file line number Diff line number Diff line change
Expand Up @@ -710,23 +710,10 @@ so you can upgrade to newer versions easier. You can remove all these styles by
.vjs-default-skin .vjs-subtitles-button:before { content: "\e00c"; }

/* There's unfortunately no CC button in FontAwesome, so we need
to manually create one. Please +1 the fontawesome request.
to use another font. Please +1 the fontawesome request.
https://github.com/FortAwesome/Font-Awesome/issues/968 */
.vjs-default-skin .vjs-captions-button {
font-size: 1em; /* Font icons are 1.5em */
}
.vjs-default-skin .vjs-captions-button:before {
content: "\e008";
font-family: VideoJS;
font-size: 1.5em;
line-height: 2;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
text-shadow: none;
}


Expand Down
4 changes: 3 additions & 1 deletion src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/

// HTML5 Shiv. Must be in <head> to support older browsers.
document.createElement('video');document.createElement('audio');
document.createElement('video');
document.createElement('audio');
document.createElement('track');

/**
* Doubles as the main function for users to create a player instance and also
Expand Down
31 changes: 19 additions & 12 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,18 @@ vjs.Player.prototype.getTagSettings = function(tag){

// Get tag children settings
if (tag.hasChildNodes()) {
var child, childName,
children = tag.childNodes,
i = 0,
j = children.length;
var children, child, childName, i, j;

for (; i < j; i++) {
children = tag.childNodes;

for (i=0,j=children.length; i<j; i++) {
child = children[i];
// Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
childName = child.nodeName.toLowerCase();

if (childName === 'source') {
options['sources'].push(vjs.getAttributeValues(child));

} else if (childName === 'track') {
options['tracks'].push(vjs.getAttributeValues(child));

}
}
}
Expand All @@ -148,12 +144,23 @@ vjs.Player.prototype.createEl = function(){
// so we'll need to turn off any default tracks if we're manually doing
// captions and subtitles. videoElement.textTracks
if (tag.hasChildNodes()) {
var nrOfChildNodes = tag.childNodes.length;
for (var i=0,j=tag.childNodes;i<nrOfChildNodes;i++) {
if (j[0].nodeName.toLowerCase() == 'source' || j[0].nodeName.toLowerCase() == 'track') {
tag.removeChild(j[0]);
var nodes, nodesLength, i, node, nodeName, removeNodes;

nodes = tag.childNodes;
nodesLength = nodes.length;
removeNodes = [];

while (nodesLength--) {
node = nodes[nodesLength];
nodeName = node.nodeName.toLowerCase();
if (nodeName === 'source' || nodeName === 'track') {
removeNodes.push(node);
}
}

for (i=0; i<removeNodes.length; i++) {
tag.removeChild(removeNodes[i]);
}
}

// Make sure tag ID exists
Expand Down