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; break;
} }
if (ref.current) { if (ref.current) {
ref.current.currentTime = 0; try {
await ref.current.play(); ref.current.currentTime = 0;
await ref.current.play();
} catch (e) {
console.log("Couldn't play sound effect", e);
}
} else { } else {
console.log("No media element found"); console.log("No media element found");
} }

View file

@ -68,9 +68,15 @@ export const useMediaStream = (
audioOutputDevice && audioOutputDevice &&
mediaRef.current !== undefined mediaRef.current !== undefined
) { ) {
console.log(`useMediaStream setSinkId ${audioOutputDevice}`); if (mediaRef.current.setSinkId) {
// Chrome for Android doesn't support this console.log(
mediaRef.current.setSinkId?.(audioOutputDevice); `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]); }, [audioOutputDevice]);