Merge branch 'develop' of https://github.com/Selz/plyr into develop
# Conflicts: # dist/plyr.js
This commit is contained in:
commit
4a2866d05f
4
dist/plyr.js
vendored
4
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
22
readme.md
22
readme.md
@ -672,7 +672,12 @@ player.source({
|
|||||||
srclang:'en',
|
srclang:'en',
|
||||||
src: '/path/to/captions.vtt',
|
src: '/path/to/captions.vtt',
|
||||||
default: true
|
default: true
|
||||||
}]
|
}],
|
||||||
|
loopKeyEvents: {
|
||||||
|
toggleLoop: 76,
|
||||||
|
loopin: 73,
|
||||||
|
loopout: 79
|
||||||
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -988,6 +993,21 @@ By default, a player will bind the following keyboard shortcuts when it has focu
|
|||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>Toggle captions</td>
|
<td>Toggle captions</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>l</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Toggle Loop All/No Loop</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>i</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Set the start marker of the loop</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>o</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Set the end marker of the loop</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -2471,7 +2471,7 @@
|
|||||||
|
|
||||||
// Toggle loop
|
// Toggle loop
|
||||||
function toggleLoop(type) {
|
function toggleLoop(type) {
|
||||||
if (!inArray(['start', 'end', 'all'], type)) {
|
if (!inArray(['start', 'end', 'all', 'toggle'], type)) {
|
||||||
type = 'none';
|
type = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2496,11 +2496,21 @@
|
|||||||
|
|
||||||
case 'all':
|
case 'all':
|
||||||
config.loop.start = 0;
|
config.loop.start = 0;
|
||||||
config.loop.end = plyr.media.duration;
|
config.loop.end = plyr.media.duration - 2;
|
||||||
config.loop.indicator.start = 0;
|
config.loop.indicator.start = 0;
|
||||||
config.loop.indicator.end = 100;
|
config.loop.indicator.end = 100;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'toggle':
|
||||||
|
if (config.loop) {
|
||||||
|
config.loop.start = 0;
|
||||||
|
config.loop.end = null;
|
||||||
|
} else {
|
||||||
|
config.loop.start = 0;
|
||||||
|
config.loop.end = plyr.media.duration - 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
config.loop.start = 0;
|
config.loop.start = 0;
|
||||||
config.loop.end = null;
|
config.loop.end = null;
|
||||||
@ -3520,6 +3530,9 @@
|
|||||||
var allowed = [48, 49, 50, 51, 52, 53, 54, 56, 57, 75, 77, 70, 67];
|
var allowed = [48, 49, 50, 51, 52, 53, 54, 56, 57, 75, 77, 70, 67];
|
||||||
var count = get().length;
|
var count = get().length;
|
||||||
|
|
||||||
|
//add also to allowed the keys of looping events
|
||||||
|
allowed = allowed.concat(Object.values(config.loopKeyEvents));
|
||||||
|
|
||||||
// Only handle global key press if there's only one player
|
// Only handle global key press if there's only one player
|
||||||
// and the key is in the allowed keys
|
// and the key is in the allowed keys
|
||||||
// and if the focused element is not editable (e.g. text input)
|
// and if the focused element is not editable (e.g. text input)
|
||||||
@ -3565,8 +3578,9 @@
|
|||||||
// Which keycodes should we prevent default
|
// 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];
|
var preventDefault = [48, 49, 50, 51, 52, 53, 54, 56, 57, 32, 75, 38, 40, 77, 39, 37, 70, 67];
|
||||||
var checkFocus = [38, 40];
|
var checkFocus = [38, 40];
|
||||||
|
var loopKeyEventsValues = Object.values(config.loopKeyEvents);
|
||||||
|
|
||||||
if (inArray(checkFocus, code)) {
|
if (inArray(checkFocus, code) || inArray(loopKeyEventsValues, code)) {
|
||||||
var focused = getFocusElement();
|
var focused = getFocusElement();
|
||||||
|
|
||||||
if (is.htmlElement(focused) && getFocusElement().type === "radio") {
|
if (is.htmlElement(focused) && getFocusElement().type === "radio") {
|
||||||
@ -3645,6 +3659,28 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Loop events
|
||||||
|
var loopKeyBindings = config.loopKeyEvents;
|
||||||
|
var hasBindedKey = loopKeyEventsValues.filter(function(el) {
|
||||||
|
return preventDefault.indexOf(el) > -1;
|
||||||
|
}).length >= 1;
|
||||||
|
|
||||||
|
if (hasBindedKey) {
|
||||||
|
loopKeyBindings = defaults.loopKeyEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case loopKeyBindings.toggleLoop:
|
||||||
|
toggleLoop('toggle');
|
||||||
|
break;
|
||||||
|
case loopKeyBindings.loopin:
|
||||||
|
toggleLoop('loopin');
|
||||||
|
break;
|
||||||
|
case loopKeyBindings.loopout:
|
||||||
|
toggleLoop('loopout');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Escape is handle natively when in full screen
|
// Escape is handle natively when in full screen
|
||||||
// So we only need to worry about non native
|
// So we only need to worry about non native
|
||||||
if (!support.fullscreen && plyr.isFullscreen && code === 27) {
|
if (!support.fullscreen && plyr.isFullscreen && code === 27) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user