Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] mediaSession missing on Linux #6913

Open
oofdere opened this issue May 9, 2023 · 13 comments
Open

[bug] mediaSession missing on Linux #6913

oofdere opened this issue May 9, 2023 · 13 comments

Comments

@oofdere
Copy link

oofdere commented May 9, 2023

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:

@FabianLars
Copy link
Member

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.

@oofdere
Copy link
Author

oofdere commented May 9, 2023

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:
image

@wusyong
Copy link
Member

wusyong commented May 10, 2023

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

@oofdere
Copy link
Author

oofdere commented May 10, 2023

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/

@oofdere
Copy link
Author

oofdere commented May 11, 2023

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.

@wusyong wusyong self-assigned this May 11, 2023
@wusyong wusyong changed the title [feat] Media Notifications (Media Session API) [bug] mediaSession missing on Linux May 11, 2023
@wusyong
Copy link
Member

wusyong commented May 11, 2023

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

@chiqors
Copy link

chiqors commented Jun 4, 2023

what's the status for windows? notification action buttons?

@FabianLars
Copy link
Member

@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.

@startup-stack-sculptor
Copy link

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.");
}

@abcdefghijorngarbosaxyz
Copy link

abcdefghijorngarbosaxyz commented Jun 21, 2023

what's the status for windows? notification action buttons?

I can confirm that Media Session API does work on Windows 10 with WebView2.

image

@chiqors
Copy link

chiqors commented Jun 22, 2023

what's the status for windows? notification action buttons?

I can confirm that Media Session API does work on Windows 10 with WebView2.

image

Thanks for reporting it. I couldn't have a time to test it

@learncodingforweb
Copy link

any update on linux webkit to open usb web camera

@Serial-ATA
Copy link

I've re-enabled MediaSession by default (WebKit/WebKit@32334c7). Now it's just a waiting game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests

9 participants