Our new developer documentation is now available. Please check it out!
OdinAudioStatsEvent
On this page
type OdinAudioStatsEvent = (event: IOdinEvent<IOdinAudioStatsEventPayload>)
Discussion
The OdinAudioStatsEvent
event is emitted on OdinRoom
instances every second and provides access to internal Opus encoder/decoder statistics, which can be used for diagnostic purposes.
Events are inheriting from IOdinEvent
and provide an object described by IOdinAudioStatsEventPayload
in the payload
property of the event.
Event Scopes
Example
OdinAudioStatsEvent Example
import { OdinClient } from '@4players/odin';
const startOdin = async function (token: string) {
// Authenticate using a token obtained externally and spawn a room instance
const odinRoom = await OdinClient.initRoom(token);
// Listen for audio stats updates
odinRoom.addEventListener('AudioStats', (event) => {
console.log('Audio stats received:', event.payload);
});
// Join the room
odinRoom.join();
// Create a new audio stream for our default capture device and append it to the room
navigator.mediaDevices.getUserMedia({ audio: true }).then((mediaStream) => {
odinRoom.createMedia(mediaStream);
});
};
startOdin('__YOUR TOKEN__').then(() => {
console.log('Started ODIN');
});
Parameters
Name | Type | Description |
---|---|---|
event | IOdinEvent<IOdinAudioStatsEventPayload> |