Skip to content

Commit 63ef759

Browse files
committed
feat: add enableSeekPause option
1 parent 8725196 commit 63ef759

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

videojs.hotkeys.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
documentHotkeysFocusElementFilter: function () { return false },
4242
enableModifiersForNumbers: true,
4343
enableInactiveFocus: true,
44+
enableSeekPause: true,
4445
skipInitialFocus: false,
4546
playPauseKey: playPauseKey,
4647
rewindKey: rewindKey,
@@ -77,6 +78,7 @@
7778
documentHotkeysFocusElementFilter = options.documentHotkeysFocusElementFilter,
7879
enableModifiersForNumbers = options.enableModifiersForNumbers,
7980
enableInactiveFocus = options.enableInactiveFocus,
81+
enableSeekPause = options.enableSeekPause,
8082
skipInitialFocus = options.skipInitialFocus;
8183

8284
var videojsVer = videojs.VERSION;
@@ -163,23 +165,37 @@
163165
// Seeking with the left/right arrow keys
164166
case cRewind: // Seek Backward
165167
ePreventDefault();
168+
if (enableSeekPause) {
169+
wasPlaying = !player.paused();
170+
if (wasPlaying) player.pause();
171+
}
166172
seekTime = player.currentTime() - seekStepD(event);
167173
// The flash player tech will allow you to seek into negative
168174
// numbers and break the seekbar, so try to prevent that.
169175
if (seekTime <= 0) {
170176
seekTime = 0;
171177
}
172178
player.currentTime(seekTime);
179+
if (enableSeekPause) {
180+
if (wasPlaying) silencePromise(player.play());
181+
}
173182
break;
174183
case cForward: // Seek Forward
175184
ePreventDefault();
185+
if (enableSeekPause) {
186+
wasPlaying = !player.paused();
187+
if (wasPlaying) player.pause();
188+
}
176189
seekTime = player.currentTime() + seekStepD(event);
177190
// Fixes the player not sending the end event if you
178191
// try to seek past the duration on the seekbar.
179192
if (seekTime >= duration) {
180193
seekTime = wasPlaying ? duration - .001 : duration;
181194
}
182195
player.currentTime(seekTime);
196+
if (enableSeekPause) {
197+
if (wasPlaying) silencePromise(player.play());
198+
}
183199
break;
184200

185201
// Volume control with the up/down arrow keys

0 commit comments

Comments
 (0)