Skip to content

Commit

Permalink
Issue 991 - Subtitles Fail in Safari
Browse files Browse the repository at this point in the history
It appears there are different behaviours for text cues on
safari compared to other browsers. We were using "auto" for
position, but Safari does not support setting that value for
position. The spec says that the default value is "auto", so
by not setting it, we can assume that it will be "auto".

Closes #991
Closes #1012

Change-Id: Ibedc5f01f72138df85b911bb5112d40f2f327ad3
  • Loading branch information
vaage committed Sep 11, 2017
1 parent e37aaed commit 7628bdd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/text/simple_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ shaka.text.SimpleTextDisplayer.prototype.convertToTextTrackCue_ =
}

var Cue = shaka.text.Cue;
/** @type {VTTCue} */
var vttCue = new VTTCue(shakaCue.startTime,
shakaCue.endTime,
shakaCue.payload);
Expand All @@ -193,14 +194,13 @@ shaka.text.SimpleTextDisplayer.prototype.convertToTextTrackCue_ =
vttCue.size = shakaCue.size;
try {
// Safari 10 seems to throw on align='center'.
// Catch any exception and let the workaround below take care of it.
vttCue.align = shakaCue.textAlign;
} catch (exception) {}

if (shakaCue.textAlign == 'center' && vttCue.align != 'center') {
// Workaround for a Chrome bug http://crbug.com/663797
// Chrome does not support align = 'center'
vttCue.position = 'auto';
// We want vttCue.position = 'auto'. By default, |position| is set to
// "auto". If we set it to "auto" safari will throw an exception, so we
// must rely on the default value.
vttCue.align = 'middle';
}

Expand Down

0 comments on commit 7628bdd

Please sign in to comment.