Merge pull request #418 from vector-im/dbkr/catch_exceptions

Catch an exception & add log line on setsinkid
This commit is contained in:
David Baker 2022-06-28 15:15:25 +01:00 committed by GitHub
commit 33461f5ac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -58,8 +58,12 @@ export const usePTTSounds = (): PTTSounds => {
break;
}
if (ref.current) {
ref.current.currentTime = 0;
await ref.current.play();
try {
ref.current.currentTime = 0;
await ref.current.play();
} catch (e) {
console.log("Couldn't play sound effect", e);
}
} else {
console.log("No media element found");
}

View file

@ -68,9 +68,15 @@ export const useMediaStream = (
audioOutputDevice &&
mediaRef.current !== undefined
) {
console.log(`useMediaStream setSinkId ${audioOutputDevice}`);
// Chrome for Android doesn't support this
mediaRef.current.setSinkId?.(audioOutputDevice);
if (mediaRef.current.setSinkId) {
console.log(
`useMediaStream setting output setSinkId ${audioOutputDevice}`
);
// Chrome for Android doesn't support this
mediaRef.current.setSinkId(audioOutputDevice);
} else {
console.log("Can't set output - no setsinkid");
}
}
}, [audioOutputDevice]);