OpenVidu screen share stop eventlistener не работает
Я работаю над совместным использованием экрана OpenVidu в проекте ionic 4. Он работает нормально, но я пытаюсь прослушать нажатие кнопки остановки совместного доступа, которая не работает. Код, упомянутый в их документации, здесь не работает.
initPublisher() {
this.publisherToggle = this.OV.initPublisher(undefined, {
audioSource: undefined, // The source of audio. If undefined default microphone
videoSource: undefined, // The source of video. If undefined default webcam
publishAudio: this.publishAudio, // Whether you want to start publishing with your audio unmuted or not
publishVideo: this.publishVideo, // Whether you want to start publishing with your video enabled or not
resolution: VideoResolution.low, // '640x480', // The resolution of your video
frameRate: this.videoFramerate, // The frame rate of your video
insertMode: 'APPEND', // How the video is inserted in the target element 'video-container'
mirror: true, // Whether to mirror your local video or not
});
// this.publisherToggle = publisher;
console.log('this.OV.initPublisher');
// --- 6) Publish your stream ---
if (this.newPublisher) {
this.publisherToggle.once('accessAllowed', () => {
this.session.unpublish(this.newPublisher);
// this.session.publish(this.publisherToggle);
});
}
this.session.publish(this.publisherToggle).then(() => {
console.log('session.publish');
// Store our Publisher
this.publisher = this.publisherToggle;
})
.catch(error => {
console.log('init publisher error', error.code, error.message);
});
}
Code to share screen:
shareScreen() {
if (this.isScreenShared) {
this._util.showToast('Screen sharing is on. Please stop it first.');
} else {
this.OV.initPublisherAsync(undefined, {
videoSource: "screen"
}).then(publisher => {
publisher.stream.getMediaStream().addEventListener('inactive', () => {
console.log('User pressed the "Stop sharing" button');
this.initPublisher();
this.isScreenShared = false;
});
});
this.isScreenShared = true;
}
}