Skip to content

Commit

Permalink
Firefox and Edge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Potts committed Aug 21, 2016
1 parent a806235 commit 4610f4a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This version contains several ***breaking changes***:
- `setup()` has been reverted to pre v1.8.0 behaviour; meaning it will return the *instance* rather than the *element*. This is because the reference to the instance is no longer added to the original element (see below).
- The reference to the `plyr` instance is now added to the media element rather than original container. This is because if a container with multiple children was passed to `setup()` the references to all instances would have been added to the container, creating issues. I would recommend using the return value from `setup()` or the new `get()` method to access the instance.
- Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This *may* break any custom styling based on DOM position.
- Players no longer seek to 0 on 'ended' - this is to fix a bug with Microsoft Edge as it triggers 'ended' on media change for whatever reason. They'll never change ;-)

And some other changes and bug fixes:

Expand Down
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ <h1>Plyr</h1>
</main>

<!-- Plyr core script -->
<script src="../dist/plyr.js"></script>
<!--<script src="../src/js/plyr.js"></script>-->
<!--<script src="../dist/plyr.js"></script>-->
<script src="../src/js/plyr.js"></script>

<!-- Docs script -->
<script src="dist/demo.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions dist/plyr.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/js/plyr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2903,6 +2903,12 @@
var code = getKeyCode(event),
pressed = event.type === 'keydown';

// If the event is bubbled from the media element
// Firefox doesn't get the keycode for whatever reason
if (!_is.number(code)) {
return;
}

// Seek by the number keys
function seekByKey() {
// Get current duration
Expand All @@ -2920,6 +2926,14 @@
// Handle the key on keydown
// Reset on keyup
if (pressed) {
// Which keycodes should we prevent default
var preventDefault = [48,49,50,51,52,53,54,56,57,32,75,38,40,77,39,37,70,67];

// If the code is found prevent default (e.g. prevent scrolling for arrows)
if (_inArray(preventDefault, code)) {
event.preventDefault();
}

switch(code) {
// 0-9
case 48:
Expand Down Expand Up @@ -3155,6 +3169,7 @@
}

// Proxy events to container
// Bubble up key events for Edge
_on(plyr.media, config.events.concat(['keyup', 'keydown']).join(' '), function(event) {
_triggerEvent(plyr.container, event.type, true);
});
Expand Down

0 comments on commit 4610f4a

Please sign in to comment.