fix(theme): keep video unmuted with persistent volume knob on launch
This commit is contained in:
1 parent
e861cda23d
commit
ce572de0d2
9 files changed
+164
-142
No files matched your search
@@ -136,6 +136,9 @@ pub fn run() {
|
||||
if let Err(error) = macos::allow_media_autoplay(&window) {
|
||||
log::warn!(target: "launcher", "{error}");
|
||||
}
|
||||
if let Err(error) = macos::activate_and_focus_window(&window) {
|
||||
log::warn!(target: "launcher", "Could not focus launcher window on startup: {error}");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -235,6 +238,9 @@ pub fn run() {
|
||||
if let Err(error) = macos::allow_media_autoplay(&window) {
|
||||
log::warn!(target: "launcher", "{error}");
|
||||
}
|
||||
if let Err(error) = macos::activate_and_focus_window(&window) {
|
||||
log::warn!(target: "launcher", "Could not focus launcher window on ready: {error}");
|
||||
}
|
||||
}
|
||||
|
||||
presence::handle_run_event(app, &event);
|
||||
|
||||
+20
-1
@@ -96,6 +96,14 @@ pub fn allow_media_autoplay(window: &tauri::WebviewWindow) -> Result<(), String>
|
||||
use objc2::msg_send;
|
||||
use objc2::runtime::AnyObject;
|
||||
|
||||
unsafe extern "C" {
|
||||
fn object_getInstanceVariable(
|
||||
obj: *mut AnyObject,
|
||||
name: *const std::ffi::c_char,
|
||||
out_value: *mut *mut std::ffi::c_void,
|
||||
) -> *const std::ffi::c_void;
|
||||
}
|
||||
|
||||
window
|
||||
.with_webview(|webview| unsafe {
|
||||
let webview = webview.inner() as *mut AnyObject;
|
||||
@@ -103,7 +111,18 @@ pub fn allow_media_autoplay(window: &tauri::WebviewWindow) -> Result<(), String>
|
||||
return;
|
||||
}
|
||||
|
||||
let configuration: *mut AnyObject = msg_send![webview, configuration];
|
||||
// -[WKWebView configuration] returns a copy. To affect live playback,
|
||||
// access the internal `_configuration` ivar directly when available.
|
||||
let mut raw_config: *mut std::ffi::c_void = std::ptr::null_mut();
|
||||
let ivar_name = c"_configuration";
|
||||
let ivar = object_getInstanceVariable(webview, ivar_name.as_ptr(), &mut raw_config);
|
||||
let configuration: *mut AnyObject = if !ivar.is_null() && !raw_config.is_null() {
|
||||
log::debug!(target: "launcher", "Accessing live WKWebView._configuration ivar");
|
||||
raw_config as *mut AnyObject
|
||||
} else {
|
||||
msg_send![webview, configuration]
|
||||
};
|
||||
|
||||
if configuration.is_null() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"decorations": false,
|
||||
"resizable": false,
|
||||
"maximizable": false,
|
||||
"shadow": true
|
||||
"shadow": true,
|
||||
"focus": true
|
||||
}
|
||||
],
|
||||
"withGlobalTauri": true,
|
||||
|
||||
Reference in new issue
Block a user