Skip to content

Commit

Permalink
Merge pull request #40 from instructure/feat-fix-playback-ie11
Browse files Browse the repository at this point in the history
Support changing the playbackRate in IE11
  • Loading branch information
cwhitten authored Nov 14, 2017
2 parents 0402b2b + a79da02 commit 83c429f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
19 changes: 16 additions & 3 deletions build/mediaelement-and-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4227,8 +4227,10 @@ function constrainedSeekTo(player, media, targetTime) {
};
togglePlayPause('pse');


media.addEventListener('play',function() {
if (t.options.playbackRate) {
media.playbackRate = t.options.playbackRate;
}
togglePlayPause('play');
}, false);
media.addEventListener('playing',function() {
Expand All @@ -4237,6 +4239,9 @@ function constrainedSeekTo(player, media, targetTime) {


media.addEventListener('pause',function() {
if (t.options.playbackRate) {
media.playbackRate = t.options.playbackRate;
}
togglePlayPause('pse');
}, false);
media.addEventListener('paused',function() {
Expand Down Expand Up @@ -5574,8 +5579,16 @@ function constrainedSeekTo(player, media, targetTime) {

var newSpeed = $(this).attr('value');
playbackSpeed = newSpeed;
media.playbackRate = parseFloat(newSpeed);
speedButton.find('button')
var newPlaybackRate = parseFloat(newSpeed);
media.playbackRate = newPlaybackRate;

// IE11 doesn't remember the user-selected playbackRate once
// clicking play/pause after setting the rate, so we save
// the value to `this` and reference it in the play/pause handler
// see: mep-feature-playpause.js
t.options.playbackRate = newPlaybackRate;

speedButton.find('button')
.html(getSpeedNameFromValue(newSpeed))
.attr('aria-label', speedLabel(newSpeed));
speedButton.find('.mejs-speed-selected').removeClass('mejs-speed-selected');
Expand Down
6 changes: 3 additions & 3 deletions build/mediaelement-and-player.min.js

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions build/mediaelementplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1736,8 +1736,10 @@ function constrainedSeekTo(player, media, targetTime) {
};
togglePlayPause('pse');


media.addEventListener('play',function() {
if (t.options.playbackRate) {
media.playbackRate = t.options.playbackRate;
}
togglePlayPause('play');
}, false);
media.addEventListener('playing',function() {
Expand All @@ -1746,6 +1748,9 @@ function constrainedSeekTo(player, media, targetTime) {


media.addEventListener('pause',function() {
if (t.options.playbackRate) {
media.playbackRate = t.options.playbackRate;
}
togglePlayPause('pse');
}, false);
media.addEventListener('paused',function() {
Expand Down Expand Up @@ -3083,8 +3088,16 @@ function constrainedSeekTo(player, media, targetTime) {

var newSpeed = $(this).attr('value');
playbackSpeed = newSpeed;
media.playbackRate = parseFloat(newSpeed);
speedButton.find('button')
var newPlaybackRate = parseFloat(newSpeed);
media.playbackRate = newPlaybackRate;

// IE11 doesn't remember the user-selected playbackRate once
// clicking play/pause after setting the rate, so we save
// the value to `this` and reference it in the play/pause handler
// see: mep-feature-playpause.js
t.options.playbackRate = newPlaybackRate;

speedButton.find('button')
.html(getSpeedNameFromValue(newSpeed))
.attr('aria-label', speedLabel(newSpeed));
speedButton.find('.mejs-speed-selected').removeClass('mejs-speed-selected');
Expand Down
6 changes: 3 additions & 3 deletions build/mediaelementplayer.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/js/mep-feature-playpause.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
};
togglePlayPause('pse');


media.addEventListener('play',function() {
if (t.options.playbackRate) {
media.playbackRate = t.options.playbackRate;
}
togglePlayPause('play');
}, false);
media.addEventListener('playing',function() {
Expand All @@ -60,6 +62,9 @@


media.addEventListener('pause',function() {
if (t.options.playbackRate) {
media.playbackRate = t.options.playbackRate;
}
togglePlayPause('pse');
}, false);
media.addEventListener('paused',function() {
Expand Down
12 changes: 10 additions & 2 deletions src/js/mep-feature-speed.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@

var newSpeed = $(this).attr('value');
playbackSpeed = newSpeed;
media.playbackRate = parseFloat(newSpeed);
speedButton.find('button')
var newPlaybackRate = parseFloat(newSpeed);
media.playbackRate = newPlaybackRate;

// IE11 doesn't remember the user-selected playbackRate once
// clicking play/pause after setting the rate, so we save
// the value to `this` and reference it in the play/pause handler
// see: mep-feature-playpause.js
t.options.playbackRate = newPlaybackRate;

speedButton.find('button')
.html(getSpeedNameFromValue(newSpeed))
.attr('aria-label', speedLabel(newSpeed));
speedButton.find('.mejs-speed-selected').removeClass('mejs-speed-selected');
Expand Down

0 comments on commit 83c429f

Please sign in to comment.