Class StreamSuccessAudioSwitch

Handles the switching of the audio stream upon successful stream connection.

The options for the audio stream success switch.

The new media stream containing the audio track.

The parameters required for setting up the audio stream.

The current audio producer.

The local audio producer.

The socket connection for communication.

The local socket connection for communication.

The name of the room.

The local media stream.

The local audio stream.

The audio parameters.

Indicates if the audio is paused.

Indicates if the audio is already on.

Indicates if the transport is created.

Additional audio parameters.

The default audio device ID.

The user default audio input device.

The label of the host.

Indicates if the main window should be updated.

Indicates if the video is already on.

The level of the participant.

Indicates if the screen is locked.

Indicates if the screen is shared.

Function to update the audio producer.

Function to update the local audio producer.

Function to update the local stream.

Function to update the audio parameters.

Function to update the default audio device ID.

Function to update the user default audio input device.

Function to update the main window.

Function to pause execution for a specified time.

Function to prepopulate user media.

Function to create a send transport.

Function to connect the send transport for audio.

A promise that resolves when the audio stream switch is complete.

const options = {
stream: newAudioStream, // MediaStream object containing the new audio track
parameters: {
audioProducer: currentAudioProducer,
localAudioProducer: localAudioProducerInstance,
localSocket: localSocketInstance,
socket: socketInstance,
roomName: "Room1",
localStream: null,
localStreamAudio: null,
audioParams: audioProducerOptions,
audioPaused: false,
audioAlreadyOn: true,
transportCreated: false,
audioParamse: additionalAudioParams,
defAudioID: "default-audio-device-id",
userDefaultAudioInputDevice: "user-input-device-id",
hostLabel: "Host",
islevel: "1",
videoAlreadyOn: false,
lock_screen: false,
shared: false,
updateAudioProducer: updateAudioProducerFunction,
updateLocalAudioProducer: updateLocalAudioProducerFunction,
updateLocalStream: updateLocalStreamFunction,
updateAudioParams: updateAudioParamsFunction,
updateDefAudioID: updateDefAudioIDFunction,
updateUserDefaultAudioInputDevice: updateUserDefaultAudioInputDeviceFunction,
updateUpdateMainWindow: updateMainWindowFunction,
sleep: sleepFunction,
prepopulateUserMedia: prepopulateUserMediaFunction,
createSendTransport: createSendTransportFunction,
connectSendTransportAudio: connectSendTransportAudioFunction,
},
};

streamSuccessAudioSwitch(options)
.then(() => {
console.log('Audio stream switched successfully');
})
.catch(error => {
console.error('Error switching audio stream:', error);
});

Constructors

Methods

  • Handles the switching of the audio stream upon successful stream connection.

    Parameters

    Returns Promise<void>

    A promise that resolves when the audio stream switch is complete.

    const options = {
    stream: newAudioStream, // MediaStream object containing the new audio track
    parameters: {
    audioProducer: currentAudioProducer,
    localAudioProducer: localAudioProducerInstance,
    localSocket: localSocketInstance,
    socket: socketInstance,
    roomName: "Room1",
    localStream: null,
    localStreamAudio: null,
    audioParams: audioProducerOptions,
    audioPaused: false,
    audioAlreadyOn: true,
    transportCreated: false,
    audioParamse: additionalAudioParams,
    defAudioID: "default-audio-device-id",
    userDefaultAudioInputDevice: "user-input-device-id",
    hostLabel: "Host",
    islevel: "1",
    videoAlreadyOn: false,
    lock_screen: false,
    shared: false,
    updateAudioProducer: updateAudioProducerFunction,
    updateLocalAudioProducer: updateLocalAudioProducerFunction,
    updateLocalStream: updateLocalStreamFunction,
    updateAudioParams: updateAudioParamsFunction,
    updateDefAudioID: updateDefAudioIDFunction,
    updateUserDefaultAudioInputDevice: updateUserDefaultAudioInputDeviceFunction,
    updateUpdateMainWindow: updateMainWindowFunction,
    sleep: sleepFunction,
    prepopulateUserMedia: prepopulateUserMediaFunction,
    createSendTransport: createSendTransportFunction,
    connectSendTransportAudio: connectSendTransportAudioFunction,
    },
    };

    streamSuccessAudioSwitch(options)
    .then(() => {
    console.log('Audio stream switched successfully');
    })
    .catch(error => {
    console.error('Error switching audio stream:', error);
    });