Add additional video player keyboard shortcuts (#275)
* Skip forward 10 seconds ((CMD OR CTRL) ALT right) Skip back 10 seconds ((CMD OR CTRL) ALT left) Increase video speed ((CMD OR CTRL) +) Decrease video speed ((CMD OR CTRL) -) * Codestyle fix * The 'steps' should be implemented in base2, standard players use 1x, 2x, 4x, 8x, 16x fixed bug with shift + "=" which is "+" * resolve conflicts * remove ide specific data make playback rate more granular add to menu skip and speed entries * intendation fix * conflict resolve * rename setPlaybackRate to changePlaybackRate setRate return boolean depending on whether this cast target supports setting the playback rate. if setRate returns false - don`t change state redundant else if statement in changePlaybackRate function
This commit is contained in:
@@ -285,6 +285,12 @@ function dispatch (action, ...args) {
|
||||
if (action === 'playbackJump') {
|
||||
jumpToTime(args[0] /* seconds */)
|
||||
}
|
||||
if (action === 'skip') {
|
||||
jumpToTime(state.playing.currentTime + (args[0] /* direction */ * 10))
|
||||
}
|
||||
if (action === 'changePlaybackRate') {
|
||||
changePlaybackRate(args[0] /* direction */)
|
||||
}
|
||||
if (action === 'changeVolume') {
|
||||
changeVolume(args[0] /* increase */)
|
||||
}
|
||||
@@ -399,7 +405,26 @@ function jumpToTime (time) {
|
||||
state.playing.jumpToTime = time
|
||||
}
|
||||
}
|
||||
|
||||
function changePlaybackRate (direction) {
|
||||
var rate = state.playing.playbackRate
|
||||
if (direction > 0 && rate >= 0.25 && rate < 2) {
|
||||
rate += 0.25
|
||||
} else if (direction < 0 && rate > 0.25 && rate <= 2) {
|
||||
rate -= 0.25
|
||||
} else if (direction < 0 && rate === 0.25) { /* when we set playback rate at 0 in html 5, playback hangs ;( */
|
||||
rate = -1
|
||||
} else if (direction > 0 && rate === -1) {
|
||||
rate = 0.25
|
||||
} else if ((direction > 0 && rate >= 1 && rate < 16) || (direction < 0 && rate > -16 && rate <= -1)) {
|
||||
rate *= 2
|
||||
} else if ((direction < 0 && rate > 1 && rate <= 16) || (direction > 0 && rate >= -16 && rate < -1)) {
|
||||
rate /= 2
|
||||
}
|
||||
state.playing.playbackRate = rate
|
||||
if (lazyLoadCast().isCasting() && !Cast.setRate(rate)) {
|
||||
state.playing.playbackRate = 1
|
||||
}
|
||||
}
|
||||
function changeVolume (delta) {
|
||||
// change volume with delta value
|
||||
setVolume(state.playing.volume + delta)
|
||||
|
||||
Reference in New Issue
Block a user