I start my session with webcam:
Then try share my screen whit this code:
async screenShare () {
const token = await this.createToken(this.idClase)
console.log(token)
this.session
.connect(token).then(() => {
const videoSource = navigator.userAgent.indexOf(‘Firefox’) !== -1 ? ‘window’ : ‘screen’
const publisher = this.OV.initPublisher(
undefined,
{
videoSource: videoSource,
publishAudio: true,
publishVideo: true,
mirror: false
}, (error) => {
if (error) {
console.error('Error while initializing publisher: ', error)
} else {
console.log(‘Publisher successfully initialized’)
}
if (error && error.name === 'SCREEN_EXTENSION_NOT_INSTALLED') {
this.setState({ showExtensionDialog: true })
} else if (error && error.name === 'SCREEN_SHARING_NOT_SUPPORTED') {
alert('Your browser does not support screen sharing')
} else if (error && error.name === 'SCREEN_EXTENSION_DISABLED') {
alert('You need to enable screen sharing extension')
} else if (error && error.name === 'SCREEN_CAPTURE_DENIED') {
this.session.unpublish(publisher)
alert('You need to choose a window or application to share')
}
}
)
publisher.once('accessAllowed', () => {
publisher.stream.getMediaStream().addEventListener('ended', () => {
console.log('ENDED: User pressed the "Stop sharing" button')
this.sharingScreen = false
this.session.unpublish(this.screenPublisher)
this.screenPublisher = undefined
})
publisher.stream.getMediaStream().addEventListener('inactive', () => {
console.log('INACTIVE: User pressed the "Stop sharing" button')
this.sharingScreen = false
this.session.unpublish(this.screenPublisher)
this.screenPublisher = undefined
})
this.session.unpublish(this.publisher)
this.screenPublisher = publisher
this.session.publish(publisher)
this.sharingScreen = true
})
publisher.once('streamPlaying', () => {
console.log('Streaming:', publisher)
})
}).catch((error) => {
console.log(
'There was an error connecting screen share:',
error.code,
error.message
)
})
},
But create another camera connection.