Skip to content

Commit

Permalink
feat: add polling
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed Mar 12, 2024
1 parent 7901606 commit ba6fa9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 1 addition & 10 deletions examples/prebuilt-react-integration/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,5 @@ import { getRoomCodeFromUrl } from './utils';
export default function App() {
const roomCode = getRoomCodeFromUrl();

return <HMSPrebuilt roomCode={roomCode}
options={{
endpoints: {
tokenByRoomCode: 'https://auth-nonprod.100ms.live/v2/token',
roomLayout: 'https://api-nonprod.100ms.live/v2/layouts/ui',
init: 'https://qa-in2-ipv6.100ms.live/init',
},
}}
screens={{ conferencing: { hls_live_streaming: { elements: { chat: null}}}}}
/>
return <HMSPrebuilt roomCode={roomCode} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class AudioSinkManager {
this.eventBus.audioTrackRemoved.subscribe(this.handleTrackRemove);
this.eventBus.audioTrackUpdate.subscribe(this.handleTrackUpdate);
this.eventBus.deviceChange.subscribe(this.handleAudioDeviceChange);
this.startPollingForDevices();
}

setListener(listener?: HMSUpdateListener) {
Expand Down Expand Up @@ -266,6 +267,19 @@ export class AudioSinkManager {
}
};

private startPollingForDevices = () => {
// device change supported, no polling needed
if ('ondevicechange' in navigator.mediaDevices) {
return;
}
this.timer = setInterval(() => {
(async () => {
await this.deviceManager.init(true, false);
await this.autoSelectAudioOutput();
})();
}, 5000);
};

/**
* Mweb is not able to play via call channel by default, this is to switch from media channel to call channel
*/
Expand Down

0 comments on commit ba6fa9b

Please sign in to comment.