|
22 | 22 | var hotkeys = function(options) {
|
23 | 23 | var player = this;
|
24 | 24 | var pEl = player.el();
|
| 25 | + var doc = document; |
25 | 26 | var def_options = {
|
26 | 27 | volumeStep: 0.1,
|
27 | 28 | seekStep: 5,
|
|
74 | 75 | }
|
75 | 76 |
|
76 | 77 | player.on('userinactive', function() {
|
77 |
| - var transitionTime, focusingPlayerTimeout, cancelFocusingPlayer; |
78 |
| - |
79 |
| - transitionTime = 1000; |
80 |
| - |
81 |
| - cancelFocusingPlayer = function(){ |
| 78 | + // When the control bar fades, re-apply focus to the player if last focus was a control button |
| 79 | + var cancelFocusingPlayer = function() { |
82 | 80 | clearTimeout(focusingPlayerTimeout);
|
83 | 81 | };
|
84 |
| - |
85 |
| - focusingPlayerTimeout = setTimeout(function(){ |
| 82 | + var focusingPlayerTimeout = setTimeout(function() { |
86 | 83 | player.off('useractive', cancelFocusingPlayer);
|
87 |
| - pEl.focus(); |
88 |
| - }, transitionTime); |
| 84 | + if (doc.activeElement.parentElement == pEl.querySelector('.vjs-control-bar')) { |
| 85 | + pEl.focus(); |
| 86 | + } |
| 87 | + }, 10); |
89 | 88 |
|
90 | 89 | player.one('useractive', cancelFocusingPlayer);
|
91 |
| - |
92 | 90 | });
|
93 | 91 |
|
94 | 92 | player.on('play', function() {
|
|
107 | 105 | if (player.controls()) {
|
108 | 106 |
|
109 | 107 | // Don't catch keys if any control buttons are focused, unless alwaysCaptureHotkeys is true
|
110 |
| - var activeEl = document.activeElement; |
| 108 | + var activeEl = doc.activeElement; |
111 | 109 | if (alwaysCaptureHotkeys ||
|
112 | 110 | activeEl == pEl ||
|
113 | 111 | activeEl == pEl.querySelector('.vjs-tech') ||
|
|
223 | 221 | if (player.controls()) {
|
224 | 222 |
|
225 | 223 | // Don't catch clicks if any control buttons are focused
|
226 |
| - var activeEl = event.relatedTarget || event.toElement || document.activeElement; |
| 224 | + var activeEl = event.relatedTarget || event.toElement || doc.activeElement; |
227 | 225 | if (activeEl == pEl ||
|
228 | 226 | activeEl == pEl.querySelector('.vjs-tech') ||
|
229 | 227 | activeEl == pEl.querySelector('.iframeblocker')) {
|
|
242 | 240 | var mouseScroll = function mouseScroll(event) {
|
243 | 241 | // When controls are disabled, hotkeys will be disabled as well
|
244 | 242 | if (player.controls()) {
|
245 |
| - var activeEl = event.relatedTarget || event.toElement || document.activeElement; |
| 243 | + var activeEl = event.relatedTarget || event.toElement || doc.activeElement; |
246 | 244 | if (alwaysCaptureHotkeys ||
|
247 | 245 | activeEl == pEl ||
|
248 | 246 | activeEl == pEl.querySelector('.vjs-tech') ||
|
|
0 commit comments