improve autoplay on chrome

This commit is contained in:
Sean Yesmunt 2019-12-03 13:09:08 -05:00
parent 8ae5a76463
commit 613c8f7a10

View file

@ -21,7 +21,6 @@ const SEEK_BACKWARD_KEYCODE = ARROW_LEFT_KEYCODE;
const SEEK_STEP = 10; // time to seek in seconds const SEEK_STEP = 10; // time to seek in seconds
const VIDEO_JS_OPTIONS: { poster?: string } = { const VIDEO_JS_OPTIONS: { poster?: string } = {
autoplay: true,
controls: true, controls: true,
preload: 'auto', preload: 'auto',
playbackRates: [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 2], playbackRates: [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 2],
@ -112,9 +111,14 @@ function VideoViewer(props: Props) {
if (!requireRedraw) { if (!requireRedraw) {
player = videojs(videoNode, videoJsOptions, function() { player = videojs(videoNode, videoJsOptions, function() {
const self = this; player.volume(volume);
self.volume(volume); player.muted(muted);
self.muted(muted); player.ready(() => {
// In the future this should be replaced with something that checks if the
// video is actually playing after calling play()
// If it's not, fall back to the play button
player.play();
});
}); });
} }