Merge pull request #910 from vector-im/dbkr/ignore_media_action
Don't pause audio streams on media actions
This commit is contained in:
commit
933dc4e2d3
1 changed files with 32 additions and 0 deletions
|
@ -158,6 +158,38 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
|
||||||
[setState]
|
[setState]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doNothingMediaActionCallback = useCallback(
|
||||||
|
(details: MediaSessionActionDetails) => {},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// disable the media action keys, otherwise audio elements get paused when
|
||||||
|
// the user presses media keys or unplugs headphones, etc.
|
||||||
|
// Note there are actions for muting / unmuting a microphone & hanging up
|
||||||
|
// which we could wire up.
|
||||||
|
const mediaActions: MediaSessionAction[] = [
|
||||||
|
"play",
|
||||||
|
"pause",
|
||||||
|
"stop",
|
||||||
|
"nexttrack",
|
||||||
|
"previoustrack",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const mediaAction of mediaActions) {
|
||||||
|
navigator.mediaSession.setActionHandler(
|
||||||
|
mediaAction,
|
||||||
|
doNothingMediaActionCallback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
for (const mediaAction of mediaActions) {
|
||||||
|
navigator.mediaSession.setActionHandler(mediaAction, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [doNothingMediaActionCallback]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function onGroupCallStateChanged() {
|
function onGroupCallStateChanged() {
|
||||||
updateState({
|
updateState({
|
||||||
|
|
Loading…
Add table
Reference in a new issue