Skip to content

Commit

Permalink
@gkatsev grouped text track errors in the console, if we can. closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Apr 19, 2016
1 parent e7d31d3 commit ae4617d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CHANGELOG
=========

## HEAD (Unreleased)
_(none)_
* @gkatsev grouped text track errors in the console, if we can ([view](https://github.com/videojs/video.js/pull/3259))

--------------------

Expand Down
13 changes: 12 additions & 1 deletion src/js/tracks/text-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ const parseCues = function(srcContent, track) {
let parser = new window.WebVTT.Parser(window,
window.vttjs,
window.WebVTT.StringDecoder());
let errors = [];

parser.oncue = function(cue) {
track.addCue(cue);
};

parser.onparsingerror = function(error) {
log.error(error);
errors.push(error);
};

parser.onflush = function() {
Expand All @@ -40,6 +41,16 @@ const parseCues = function(srcContent, track) {
};

parser.parse(srcContent);
if (errors.length > 0) {
if (console.groupCollapsed) {
console.groupCollapsed(`Text Track parsing errors for ${track.src}`);
}
errors.forEach((error) => log.error(error));
if (console.groupEnd) {
console.groupEnd();
}
}

parser.flush();
};

Expand Down

0 comments on commit ae4617d

Please sign in to comment.