Skip to content

Commit

Permalink
Merge pull request hyperaudio#115 from hyperaudio/113-captions-no-vid…
Browse files Browse the repository at this point in the history
…eo-bug

113 check to see if video exists
  • Loading branch information
maboa authored Aug 2, 2022
2 parents 08f6262 + 449bf20 commit 07c7f90
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions js/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,19 @@ var caption = function () {

var video = document.getElementById(playerId);

video.addEventListener("loadedmetadata", function() {
//var track = document.createElement("track");
var track = document.getElementById(playerId+'-vtt');
track.kind = "captions";
track.label = "English";
track.srclang = "en";
track.src = "data:text/vtt,"+encodeURIComponent(captionsVtt);
if (video !== null) {
video.addEventListener("loadedmetadata", function() {
//var track = document.createElement("track");
var track = document.getElementById(playerId+'-vtt');
track.kind = "captions";
track.label = "English";
track.srclang = "en";
track.src = "data:text/vtt,"+encodeURIComponent(captionsVtt);
video.textTracks[0].mode = "showing";
});

video.textTracks[0].mode = "showing";
});
}

video.textTracks[0].mode = "showing";

Expand Down

0 comments on commit 07c7f90

Please sign in to comment.