From 718e1e0d828bb90b0461a389d42e9a683472bae3 Mon Sep 17 00:00:00 2001 From: Daniel Jacobs Date: Mon, 25 Nov 2024 10:57:48 -0500 Subject: [PATCH] web: On browsers which support it, specify the type of audio Ruffle uses --- web/packages/core/src/plugin-polyfill.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/packages/core/src/plugin-polyfill.ts b/web/packages/core/src/plugin-polyfill.ts index 99cec3075999d..ba564b6f0cc2a 100644 --- a/web/packages/core/src/plugin-polyfill.ts +++ b/web/packages/core/src/plugin-polyfill.ts @@ -231,6 +231,9 @@ declare global { interface MimeTypeArray { install?: (mimeType: MimeType) => void; } + interface AudioSession { + type?: string; + } } /** @@ -244,6 +247,11 @@ declare global { * @param plugin The plugin to install */ export function installPlugin(plugin: RufflePlugin): void { + // This code is not polyfill related, but while messing with the navigator API, + // we can specify https://www.w3.org/TR/audio-session/#audio-session-types + if ("audioSession" in navigator) { + (navigator.audioSession as AudioSession).type = "playback"; + } if (navigator.plugins.namedItem("Shockwave Flash")) { return; }