Skip to content

Commit 82b1f29

Browse files
Set audioSession.type to playback in sheet music app (#489)
Use the Audio Session API to declare audio as media playback so the platform handles it correctly: background audio, lock screen controls, Dynamic Island integration, and bypassing the iOS silent switch.
1 parent 0be854b commit 82b1f29

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/sheet-music-server/src/mcp-app.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ const statusEl = document.getElementById("status")!;
3030
const sheetMusicEl = document.getElementById("sheet-music")!;
3131
const audioControlsEl = document.getElementById("audio-controls")!;
3232

33+
// =============================================================================
34+
// Audio Session
35+
// =============================================================================
36+
37+
// Declare this app's audio as media playback so the platform can handle it
38+
// correctly: background audio, lock screen controls, Dynamic Island, and
39+
// bypassing the iOS silent switch. See https://w3c.github.io/audio-session/
40+
if ("audioSession" in navigator) {
41+
(navigator.audioSession as { type: string }).type = "playback";
42+
}
43+
3344
// =============================================================================
3445
// ABC Rendering
3546
// =============================================================================

0 commit comments

Comments
 (0)