Skip to content

Commit

Permalink
Added support for pressing in the middle of the video to play/pause
Browse files Browse the repository at this point in the history
  • Loading branch information
Quadrubo committed May 13, 2021
1 parent 6f6e0de commit 47bc7cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,34 @@ function connectToServer(server_tmp, port_tmp) {
}
});

document.getElementsByClassName("view flex page")[1].addEventListener("click", function(e) {
console.log(e);
if(e.isTrusted){
// Human input, sending to other people
var percentage = document.getElementsByClassName("emby-slider-background-lower")[0].getAttribute("style");
percentage = percentage.split(":")[1].split("%")[0];

var play_button = document.getElementsByClassName("videoOsd-btnPause")[0];
if(play_button.getAttribute("title") == "Play") {
// Sending Play with percentage Server
sending = {
"command": "play",
"percentage": percentage
}
console.log("SENDING \"" + sending + "\" to server!");
ws.send(JSON.stringify(sending));
} else if(play_button.getAttribute("title") == "Pause") {
// Sending Play with percentage Server
sending = {
"command": "pause",
"percentage": percentage
}
console.log("SENDING \"" + sending + "\" to server!");
ws.send(JSON.stringify(sending));
}
}
})

// On next_track button press
document.getElementsByClassName("btnNextTrack")[0].addEventListener("click", function(e) {
console.log(e);
Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Emby Sync Watch",
"description": "A Chrome Extension for sync video watching on Emby.",
"version": "1.0",
"version": "1.2",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
Expand Down

0 comments on commit 47bc7cc

Please sign in to comment.