From d39aecd4a5755d83bd0765c7785d2063ba9402c2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Jun 2014 12:08:54 -0400 Subject: [PATCH] fix vtt with chrome --- dashboard-ui/scripts/mediaplayer-video.js | 17 +++++++++++++++++ dashboard-ui/scripts/mediaplayer.js | 7 ------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dashboard-ui/scripts/mediaplayer-video.js b/dashboard-ui/scripts/mediaplayer-video.js index d6d4c2f4f..bf7748152 100644 --- a/dashboard-ui/scripts/mediaplayer-video.js +++ b/dashboard-ui/scripts/mediaplayer-video.js @@ -239,6 +239,23 @@ return; } + var allTracks = video.textTracks; // get list of tracks + + for (var i = 0; i < allTracks.length; i++) { + + var track = allTracks[i]; + + // This throws an error in IE, but is fine in chrome + // In IE it's not necessary anyway because changing the src seems to be enough + try { + while (track.cues.length) { + track.removeCue(track.cues[0]); + } + } catch (e) { + console.log('Error removing cue from textTrack'); + } + } + $('track', video).each(function () { var currentSrc = this.src; diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index e810c6633..06ea89557 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -232,14 +232,7 @@ self.supportsTextTracks = function () { - // When seeking with transcoding, there repointing the track element - // to a new url (via src) doesn't seem to work. - if ($.browser.chrome) { - return false; - } - if (supportsTextTracks == null) { - supportsTextTracks = document.createElement('video').textTracks != null; }