@@ -12,11 +12,13 @@ type ErrorCallback = (errorMsg: string) => void;
1212 * @param id The session_id of the participant to observe.
1313 * @param cb The function to execute when the volume changes. Can be used to visualise audio output.
1414 * @param errorCb Error callback. Called when local audio level observer is not available in browser.
15+ * @param interval Callbacks will be executed at this freqency. If unspecified, Daily's default frequency is used.
1516 */
1617export const useAudioLevelObserver = (
1718 id : string ,
1819 cb : AudioLevelCallback ,
19- errorCb ?: ErrorCallback
20+ errorCb ?: ErrorCallback ,
21+ interval ?: number
2022) => {
2123 const daily = useDaily ( ) ;
2224 const localSessionId = useLocalSessionId ( ) ;
@@ -49,20 +51,20 @@ export const useAudioLevelObserver = (
4951 if ( ! daily || daily . isDestroyed ( ) || ! isLocal ) return ;
5052 if ( daily . isLocalAudioLevelObserverRunning ( ) ) return ;
5153 try {
52- daily . startLocalAudioLevelObserver ( ) ;
54+ daily . startLocalAudioLevelObserver ( interval ) ;
5355 } catch {
5456 errorCb ?.( 'Local audio level observer not supported in this browser' ) ;
5557 }
5658 } ,
57- [ daily , errorCb , isLocal ]
59+ [ daily , errorCb , interval , isLocal ]
5860 ) ;
5961
6062 useEffect (
6163 function maybeStartRemoteAudioObserver ( ) {
6264 if ( ! daily || daily . isDestroyed ( ) || isLocal ) return ;
6365 if ( daily . isRemoteParticipantsAudioLevelObserverRunning ( ) ) return ;
64- daily . startRemoteParticipantsAudioLevelObserver ( ) ;
66+ daily . startRemoteParticipantsAudioLevelObserver ( interval ) ;
6567 } ,
66- [ daily , isLocal ]
68+ [ daily , interval , isLocal ]
6769 ) ;
6870} ;
0 commit comments