import {
SRTC,
LocalScreenTrack,
ScreenPresets,
ScreenAudioPresets,
} from '@seastart/srtc-web-sdk';
const srtc = new SRTC();
// Create a screen sharing track and request system audio capture at the same time
const localScreenTrack = srtc.createLocalScreenTrack(
ScreenPresets['1080p'],
ScreenAudioPresets.default, // Second parameter: system audio preset
);
await localScreenTrack.startCapture();
// Get the system audio track (if the browser supports it and the user checked "Share audio")
const screenAudioTrack = localScreenTrack.getAudioTrack();
if (screenAudioTrack) {
// Publish the system audio to the channel too
await srtc.publishLocalTrack(screenAudioTrack, { desc: 'screen_audio' });
console.log('System audio published');
} else {
console.warn('System audio capture is not supported in this environment, or the user did not check "Share audio"');
}
// Publish the screen sharing video
await srtc.publishLocalTrack(localScreenTrack, { desc: 'screen' });