Skip to content

Commit

Permalink
Resume audio playback status when switching back to tab on iOS (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Jan 31, 2024
1 parent de80d36 commit 4fe4389
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-wolves-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Resume audio playback status when switching back to tab on iOS
8 changes: 8 additions & 0 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,18 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
}
// set the srcObject to null on page hide in order to prevent lock screen controls to show up for it
dummyAudioEl.srcObject = document.hidden ? null : stream;
if (!document.hidden) {
this.log.debug(
'page visible again, triggering startAudio to resume playback and update playback status',
this.logContext,
);
this.startAudio();
}
});
document.body.append(dummyAudioEl);
this.once(RoomEvent.Disconnected, () => {
dummyAudioEl?.remove();
dummyAudioEl = null;
});
}
elements.push(dummyAudioEl);
Expand Down

0 comments on commit 4fe4389

Please sign in to comment.