set min/max on playback speed

Video playback range in Chrome: [0.0625, 16]
Audio playback range in Chrome: [0.05, 4]

Setting min to 0.05 and max to 16, since outside of this range you're
not getting audio or video.

closes #26
This commit is contained in:
Ilya Grigorik
2015-03-29 11:01:55 -07:00
parent 5758280776
commit 214e296b04

View File

@@ -102,9 +102,13 @@ chrome.extension.sendMessage({}, function(response) {
if (action === 'rewind') { if (action === 'rewind') {
v.currentTime -= rewindTime; v.currentTime -= rewindTime;
} else if (action === 'faster') { } else if (action === 'faster') {
v.playbackRate += speedStep // Maxium playback speed in Chrome is set to 16:
// https://code.google.com/p/chromium/codesearch#chromium/src/media/blink/webmediaplayer_impl.cc&l=64
v.playbackRate = Math.Min(v.playbackRate + speedStep, 16);
} else if (action === 'slower') { } else if (action === 'slower') {
v.playbackRate = Math.max(v.playbackRate - speedStep, 0.00); // Audio playback is cut at 0.05:
// https://code.google.com/p/chromium/codesearch#chromium/src/media/filters/audio_renderer_algorithm.cc&l=49
v.playbackRate = Math.max(v.playbackRate - speedStep, 0.05);
} }
} }
}); });