Open oofdere opened 1 year ago
What OS + version are you on? Looking at the feature matrix on mdn it seems like it should work on Windows, macOS 12+, and with macOS working, Linux should work too.
I'm using Arch Linux with tauri = { version = "1.2.4", features = [] }
. Attempting to use the API results in the following error:
Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'navigator.mediaSession.playbackState = $state.paused ? "paused" : "playing"')
navigator.mediaSession
isn't available on the devtools console either:
You may need webkit2gtk 2.38 to get mediaSession. Here's the release note about it set by default there: https://webkitgtk.org/2022/09/16/webkitgtk2.38.0-released.html
You may need webkit2gtk 2.38 to get mediaSession. Here's the release note about it set by default there: https://webkitgtk.org/2022/09/16/webkitgtk2.38.0-released.html
I've got version 2.40 installed: https://archlinux.org/packages/extra/x86_64/webkit2gtk/
Tested on macOS 13 and mediaSession
does indeed work fine, so this seems to be a Linux bug. I can't test on Windows or mobile devices though.
A bit more imformation that might be relevant:
Operating System: Arch Linux KDE Plasma Version: 5.27.5 KDE Frameworks Version: 5.105.0 Qt Version: 5.15.9 Kernel Version: 6.3.1-arch1-1 (64-bit) Graphics Platform: Wayland
I've also got Pipewire installed if that matters. Happy to provide any additional info.
Looks like it got disabled again because some trouble couldn't resolve. See comment 10 of this ticket in Webkit bugzilla: https://bugs.webkit.org/show_bug.cgi?id=247527#c10
what's the status for windows? notification action buttons?
@chiqors As far as we know the mediasession api works fine on Windows. If you have any problems with it, please open a separate issue.
I think, wrapping the navigator.mediaSession code within feature detection and fallback logic would be a workaround it.
if ('mediaSession' in navigator) {
navigator.mediaSession.playbackState = $state.paused ? "paused" : "playing";
} else {
// Alternative code or fallback behavior for platforms without mediaSession support
console.log("MediaSession API is not supported on this platform.");
}
what's the status for windows? notification action buttons?
I can confirm that Media Session API does work on Windows 10 with WebView2.
what's the status for windows? notification action buttons?
I can confirm that Media Session API does work on Windows 10 with WebView2.
Thanks for reporting it. I couldn't have a time to test it
any update on linux webkit to open usb web camera
I've re-enabled MediaSession by default (https://github.com/WebKit/WebKit/commit/32334c785916504b99c6ecbd740052a73b86f3e0). Now it's just a waiting game.
Describe the problem
I've implemented an audio player and would like the ability for it to use the Media Session API in Tauri much like in the browser so the user can view and control their media using the system notification/lock screen UIs.
Describe the solution you'd like
I would like for Tauri to support the Media Session API, or similar, ideally on mobile and desktop.
Alternatives considered
A Rust package that does the same thing, but I haven't been able to find any packages that do this, especially cross-platform.
Additional context
Related links: