Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit c79ef4d

Browse files
committed
Misc fixes for the video player
* Fix regression introduced in 131e680 * Use the keydown event instead of onkeypress() * Make autoplay work again by using `--autoplay-policy=no-user-gesture-required` (https://developers.google.com/web/updates/2017/09/autoplay-policy-changes)
1 parent 206ba25 commit c79ef4d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/electron/app/player.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
video.currentTime = video.currentTime - 10
4747
}
4848

49-
document.onkeypress = (e) => {
50-
e = e || window.event;
51-
e.code in keyMapping ? keyMapping[e.code]() : _
52-
}
49+
document.addEventListener('keydown', (e) => {
50+
if (e.code in keyMapping) {
51+
keyMapping[e.code]();
52+
}
53+
});
5354

5455
$(function() {
5556

@@ -66,7 +67,7 @@
6667
var hls = new Hls();
6768
hls.loadSource(vid.hlsvideosource);
6869
hls.attachMedia(video);
69-
hls.on(hls.Events.MANIFEST_PARSED, function() {
70+
hls.on(Hls.Events.MANIFEST_PARSED, function() {
7071
video.play();
7172
});
7273
});

src/electron/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const isDev = require('electron-is-dev')
1818
const ffmpeg = require('fluent-ffmpeg')
1919
const async = require('async')
2020

21+
// This is required to re-enable autoplay. See:
22+
// https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
23+
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
24+
2125
let mainWindow = null
2226
let playerWindow = null
2327
let bookmarksWindow = null

0 commit comments

Comments
 (0)