add audio device selection for mpv

This commit is contained in:
jeffvli
2026-01-14 19:12:36 -08:00
parent d95204513f
commit 41054ed819
5 changed files with 132 additions and 23 deletions
@@ -89,8 +89,16 @@ export const AudioPlayers = () => {
useEffect(() => {
// Not standard, just used in chromium-based browsers. See
// https://developer.chrome.com/blog/audiocontext-setsinkid/.
// If the isElectron() check is every removed, fix this.
if (isElectron() && audioContext && 'setSinkId' in audioContext.context && audioDeviceId) {
if (!isElectron()) {
return;
}
if (playbackType !== PlayerType.WEB) {
return;
}
if (audioContext && 'setSinkId' in audioContext.context && audioDeviceId) {
const setSink = async () => {
try {
if (audioContext.context.state !== 'closed') {
@@ -103,7 +111,7 @@ export const AudioPlayers = () => {
setSink();
}
}, [audioContext, audioDeviceId]);
}, [audioContext, audioDeviceId, playbackType]);
// Listen to favorite and rating events to update queue songs
useEffect(() => {