Fix bug where playback rate could go negative
This commit is contained in:
@@ -152,26 +152,21 @@ module.exports = class PlaybackController {
|
|||||||
changePlaybackRate (direction) {
|
changePlaybackRate (direction) {
|
||||||
const state = this.state
|
const state = this.state
|
||||||
let rate = state.playing.playbackRate
|
let rate = state.playing.playbackRate
|
||||||
if (direction > 0 && rate >= 0.25 && rate < 2) {
|
if (direction > 0 && rate < 2) {
|
||||||
rate += 0.25
|
rate += 0.25
|
||||||
} else if (direction < 0 && rate > 0.25 && rate <= 2) {
|
} else if (direction < 0 && rate > 0.25 && rate <= 2) {
|
||||||
rate -= 0.25
|
rate -= 0.25
|
||||||
} else if (direction < 0 && rate === 0.25) {
|
} else if (direction > 0 && rate >= 1 && rate < 16) {
|
||||||
// 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
|
rate *= 2
|
||||||
} else if ((direction < 0 && rate > 1 && rate <= 16) ||
|
} else if (direction < 0 && rate > 1 && rate <= 16) {
|
||||||
(direction > 0 && rate >= -16 && rate < -1)) {
|
|
||||||
rate /= 2
|
rate /= 2
|
||||||
}
|
}
|
||||||
state.playing.playbackRate = rate
|
state.playing.playbackRate = rate
|
||||||
if (isCasting(state) && !Cast.setRate(rate)) {
|
if (isCasting(state) && !Cast.setRate(rate)) {
|
||||||
state.playing.playbackRate = 1
|
state.playing.playbackRate = 1
|
||||||
}
|
}
|
||||||
|
// Wait a bit before we hide the controls and header again
|
||||||
|
state.playing.mouseStationarySince = new Date().getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the volume, in range [0, 1], by some amount
|
// Change the volume, in range [0, 1], by some amount
|
||||||
|
|||||||
Reference in New Issue
Block a user