Skip to content

Commit

Permalink
Merge pull request #227 from chrisgavin/twitch-html5
Browse files Browse the repository at this point in the history
Twitch: Support the HTML 5 player, as well as the old Flash player.
  • Loading branch information
feedbee authored May 19, 2017
2 parents fa09124 + 4b3ddad commit 42bb862
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extension/keysocket-twitch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function onKeyPress(key) {
var player = null;

// Handle the Flash version of the player.
var objs = document.querySelectorAll("object");
for (var i = 0; i < objs.length; i++) {
if(objs[i].id.endsWith("-flash-player")) {
Expand All @@ -14,4 +16,10 @@ function onKeyPress(key) {
player.pauseVideo();
}
}
}

// Handle the HTML 5 version of the player.
player = document.querySelector("video");
if (player && key === PLAY) {
player.paused ? player.play() : player.pause();
}
}

0 comments on commit 42bb862

Please sign in to comment.