This example shows the generic approach to follow to listen to events.
function someMethod()
{
sfs.addEventListener(SFSAudioEvent.INIT, onAudioInitialized, this);
// Initialize the Audio Streaming System
sfs.send(new InitAudioRequest());
}
function onAudioInitialized(evtParams)
{
console.log("Audio Streaming System initialized successfully");
// Display the capture and playback devices in list components in the application interface
...
}Events
ERROR
This event is fired when the Audio Streaming System has to stop the outgoing stream automatically because of an unrecoverable capture error, for example:
- the audio capture fails to start (no capture device found, device busy or unavailable, etc.);
- the permission to access the audio capture device is revoked while a stream is in progress (through the browser settings or the operating system);
- the active capture device is removed (for example unplugged) and no other capture device is available to switch to.
In all these cases the outgoing stream is stopped (the STREAM_STOP event is fired too) and the application is notified of the reason by means of this event. Note that recoverable conditions, like the active capture device being unplugged while another one is available (which causes a seamless switch), do not fire this event.
| Name | Type | Description |
|---|---|---|
errorMessage | string | A message describing the error that caused the outgoing audio stream to stop. |
INIT
This event is fired in response to the InitAudioRequest.
Upon Audio Streaming System initialization, the client receives from the server the audio parametersset in server configuration (for example the audio encoding bitrate value).
STREAM_ADD
This event is fired when another client starts its own audio stream (by means of a StartAudioStreamRequest) in the same Room where the current client is already streaming. The event is also fired (multiple times - one per client) when the current client starts its audio stream in a Room where other clients are already streaming. In all cases the Audio Streaming System starts the audio playback automatically.
| Name | Type | Description |
|---|---|---|
audioStream | AudioStreamInfo | The object representing the audio stream received from another client. |
STREAM_REMOVE
This event is fired when another client stops its own audio stream (by means of a StopAudioStreamRequest) in the same Room where the current client is streaming. The Audio Streaming System stops the audio playback automatically and removes all references to the incoming stream.
| Name | Type | Description |
|---|---|---|
audioStream | AudioStreamInfo | The object representing the audio streams received from another client. |
STREAM_START
This event is fired in response to the StartAudioStreamRequest. The Audio Streaming System then starts the audio capture and transmission automatically; it also gets ready to receive the incoming audio streams from other clients and send them to the playback device.
| Name | Type | Description |
|---|---|---|
myAudioStream | AudioStreamInfo | The object representing the audio stream of the current client. |
STREAM_STOP
This event is fired in response to the StopAudioStreamRequest to signal that the outgoing audio stream of the current client has been stopped.
| Name | Type | Description |
|---|---|---|
myAudioStream | AudioStreamInfo | The object representing the audio stream of the current client. |
TOGGLE_MUTE
This event is fired when another client toggles the muted state of its own audio stream (by means of a ToggleMuteAudioStreamRequest) in the same Room where the current client is streaming. If the stream is muted, the audo stream is interrupted temporarily. This event can be useful to signal that a client is muted in the application UI.
| Name | Type | Description |
|---|---|---|
audioStream | AudioStreamInfo | The object representing the audio streams received from another client. |