Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

Commit 98c7eee

Browse files
author
Aaron Cooper
committed
Merge branch 'master' of https://github.com/Snazzie/PlexOnTauri
2 parents 9df44be + 9c9b945 commit 98c7eee

File tree

6 files changed

+83
-5
lines changed

6 files changed

+83
-5
lines changed

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
1818
tauri-build = { version = "2", features = [] }
1919

2020
[dependencies]
21-
tauri = { version = "2", features = [] }
21+
tauri = { version = "2", features = ["devtools"] }
2222
tauri-plugin-opener = "2"
2323
tauri-plugin-store = "2"
2424
serde = { version = "1", features = ["derive"] }

src-tauri/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn import_js_scripts_to_rust() -> PathBuf {
3838
("PIP_SCRIPT", "pip_script.js"),
3939
("PIP_OVERLAY_SCRIPT", "pip_overlay_script.js"),
4040
("ZOOM_SCRIPT", "zoom_script.js"),
41+
("BRIGHTNESS_SCRIPT", "brightness_script.js"),
4142
];
4243

4344
// Generate Rust code for each script
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
let brightnessOverlay = null;
2+
let overlayTimeout = null;
3+
4+
function showBrightnessOverlay(value) {
5+
if (!brightnessOverlay) {
6+
brightnessOverlay = document.createElement('div');
7+
brightnessOverlay.id = 'brightness-overlay';
8+
Object.assign(brightnessOverlay.style, {
9+
position: 'fixed',
10+
top: '50%',
11+
left: '50%',
12+
transform: 'translate(-50%, -50%)',
13+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
14+
color: 'white',
15+
padding: '10px 20px',
16+
borderRadius: '5px',
17+
zIndex: '10000',
18+
opacity: '0',
19+
transition: 'opacity 0.3s ease-in-out',
20+
pointerEvents: 'none', // Allow clicks to pass through
21+
fontSize: '2em'
22+
});
23+
document.body.appendChild(brightnessOverlay);
24+
}
25+
26+
brightnessOverlay.textContent = `Video Brightness: ${Math.round(value * 100)}%`;
27+
brightnessOverlay.style.opacity = '1';
28+
29+
if (overlayTimeout) {
30+
clearTimeout(overlayTimeout);
31+
}
32+
33+
overlayTimeout = setTimeout(() => {
34+
brightnessOverlay.style.opacity = '0';
35+
}, 2000); // Hide after 2 seconds
36+
}
37+
38+
39+
document.addEventListener('keydown', (event) => {
40+
const video = document.querySelector('video');
41+
if (!video) return;
42+
43+
let currentBrightness = 1;
44+
const filter = video.style.filter;
45+
const brightnessMatch = filter.match(/brightness\(([^)]+)\)/);
46+
47+
if (brightnessMatch?.[1]) {
48+
currentBrightness = Number.parseFloat(brightnessMatch[1]);
49+
}
50+
51+
let newBrightness = currentBrightness;
52+
53+
if (event.ctrlKey && event.key === '[') {
54+
// Decrease brightness
55+
newBrightness = Math.max(0.1, currentBrightness - 0.1);
56+
event.preventDefault(); // Prevent default browser action
57+
} else if (event.ctrlKey && event.key === ']') {
58+
// Increase brightness
59+
newBrightness = currentBrightness + 0.1;
60+
event.preventDefault(); // Prevent default browser action
61+
}
62+
63+
if (newBrightness !== currentBrightness) {
64+
// Update the filter property, preserving other filters if any
65+
if (brightnessMatch) {
66+
video.style.filter = filter.replace(brightnessMatch[0], `brightness(${newBrightness})`);
67+
} else {
68+
video.style.filter = `${filter} brightness(${newBrightness})`;
69+
}
70+
showBrightnessOverlay(newBrightness);
71+
}
72+
});

src-tauri/src/scripts/script.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// The constants are now directly available from the parent module
2-
use super::{FULLSCREEN_SCRIPT, PIP_OVERLAY_SCRIPT, PIP_SCRIPT, ZOOM_SCRIPT};
2+
use super::{BRIGHTNESS_SCRIPT, FULLSCREEN_SCRIPT, PIP_OVERLAY_SCRIPT, PIP_SCRIPT, ZOOM_SCRIPT};
33

44
pub fn init_script() -> String {
55
format!(
6-
"{}{}{}{}{}",
6+
"{}{}{}{}{}{}",
77
FULLSCREEN_SCRIPT,
88
ZOOM_SCRIPT,
99
PIP_SCRIPT,
1010
PIP_OVERLAY_SCRIPT,
11+
BRIGHTNESS_SCRIPT,
1112
r#"
12-
console.log('Plex event listeners injected (fullscreen, zoom, PiP, and draggable overlay)');
13+
console.log('Plex event listeners injected (fullscreen, zoom, PiP, draggable overlay, and brightness)');
1314
"#
1415
)
1516
}

src-tauri/tauri.conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"width": 1024,
1717
"height": 768,
1818
"visible": false,
19-
"maximized": false
19+
"maximized": false,
20+
"devtools": true
2021
}
2122
]
2223
},

src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ function App() {
115115
<p className="control-instruction">
116116
Use Alt + P to toggle Picture In Picture mode.
117117
</p>
118+
<p className="control-instruction">
119+
Use Ctrl + [ and Ctrl + ] to adjust video brightness.
120+
</p>
118121
</div>
119122

120123
<div className="url-input-container">

0 commit comments

Comments
 (0)