mirror of https://github.com/OpenVidu/openvidu.git
openvidu-testapp: when changing Publisher dynamically do not unpublish until new Publisher receives 'accessAllowed' event
parent
870600dc6a
commit
ab13435af8
|
@ -522,13 +522,6 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
changePublisher() {
|
changePublisher() {
|
||||||
|
|
||||||
if (!this.unpublished) {
|
|
||||||
this.session.unpublish(this.publisher);
|
|
||||||
this.removeUserData(this.session.connection.connectionId);
|
|
||||||
this.restartPublisherRecord();
|
|
||||||
}
|
|
||||||
|
|
||||||
let screenChange;
|
let screenChange;
|
||||||
if (!this.publisherChanged) {
|
if (!this.publisherChanged) {
|
||||||
if (this.sendAudio && !this.sendVideo) {
|
if (this.sendAudio && !this.sendVideo) {
|
||||||
|
@ -560,7 +553,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
this.updateVideoIcon();
|
this.updateVideoIcon();
|
||||||
this.updatePublishIcon();
|
this.updatePublishIcon();
|
||||||
|
|
||||||
this.publisher = this.OV.initPublisher(
|
const otherPublisher = this.OV.initPublisher(
|
||||||
'local-vid-' + this.session.connection.connectionId,
|
'local-vid-' + this.session.connection.connectionId,
|
||||||
{
|
{
|
||||||
audioSource: this.sendAudioChange ? undefined : false,
|
audioSource: this.sendAudioChange ? undefined : false,
|
||||||
|
@ -584,8 +577,17 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.addPublisherEvents(this.publisher);
|
this.addPublisherEvents(otherPublisher);
|
||||||
this.session.publish(this.publisher);
|
|
||||||
|
otherPublisher.once('accessAllowed', () => {
|
||||||
|
if (!this.unpublished) {
|
||||||
|
this.session.unpublish(this.publisher);
|
||||||
|
this.publisher = otherPublisher;
|
||||||
|
this.removeUserData(this.session.connection.connectionId);
|
||||||
|
this.restartPublisherRecord();
|
||||||
|
}
|
||||||
|
this.session.publish(otherPublisher);
|
||||||
|
});
|
||||||
|
|
||||||
this.publisherChanged = !this.publisherChanged;
|
this.publisherChanged = !this.publisherChanged;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue