Create Local Tracks
Before joining or starting a meeting, it is essential to create local tracks. The createLocalTracks method from ProConfManager facilitates this by allowing you to specify the types of tracks to create, such as audio and video.
Parameters:
devices(optional): An array specifying the types of tracks to create. Include"audio"and/or"video"in the array to create audio and video tracks respectively.videoName(optional): Specifies the name for the video track.audioName(optional): Specifies the name for the audio track.cameraDeviceId(optional): Specifies the device ID of the camera for the video track.micDeviceId(optional): Specifies the device ID of the microphone for the audio track.
Usage Examples:
Option 1: Create Local Tracks with Default Audio and Video Input
This example shows how to create local audio and video tracks using any available audio/video input.
proconfManager
.createLocalTracks({ devices: ['audio', 'video'] })
.then((tracks) => {
// Handle the tracks as needed
console.log(tracks);
})
.catch((error) => {
console.error('Error creating local tracks:', error);
});
Option 2: Create Local Tracks with Specified Audio and Video Names
This example demonstrates how to create local tracks by specifying names for the audio and video tracks.
proconfManager
.createLocalTracks({ videoName: 'MyVideoTrack', audioName: 'MyAudioTrack' })
.then((tracks) => {
// Handle the tracks as needed
console.log(tracks);
})
.catch((error) => {
console.error('Error creating local tracks:', error);
});
Option 3: Create Local Tracks with Specified Camera and Microphone Device IDs
This example shows how to create local tracks by specifying the device IDs for the camera and microphone.
proconfManager
.createLocalTracks({ cameraDeviceId: 'camera-id-123', micDeviceId: 'mic-id-456' })
.then((tracks) => {
// Handle the tracks as needed
console.log(tracks);
})
.catch((error) => {
console.error('Error creating local tracks:', error);
});
In these examples, replace 'camera-id-123' and 'mic-id-456' with the actual device IDs for your camera and microphone. Similarly, replace 'MyVideoTrack' and 'MyAudioTrack' with the names of your video and audio tracks. The tracks object returned in the promise will contain the created local tracks, which you can then use as needed for your application.