mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: Publisher publishAudio and publishVideo may be called without a Session
parent
5f1565cac0
commit
2a85971dfa
|
@ -90,6 +90,8 @@ export class Publisher extends StreamManager {
|
||||||
*
|
*
|
||||||
* #### Events dispatched
|
* #### Events dispatched
|
||||||
*
|
*
|
||||||
|
* > _Only if `Session.publish(Publisher)` has been called for this Publisher_
|
||||||
|
*
|
||||||
* The [[Session]] object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"audioActive"` and `reason` set to `"publishAudio"`
|
* The [[Session]] object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"audioActive"` and `reason` set to `"publishAudio"`
|
||||||
* The [[Publisher]] object of the local participant will also dispatch the exact same event
|
* The [[Publisher]] object of the local participant will also dispatch the exact same event
|
||||||
*
|
*
|
||||||
|
@ -105,22 +107,24 @@ export class Publisher extends StreamManager {
|
||||||
this.stream.getMediaStream().getAudioTracks().forEach((track) => {
|
this.stream.getMediaStream().getAudioTracks().forEach((track) => {
|
||||||
track.enabled = value;
|
track.enabled = value;
|
||||||
});
|
});
|
||||||
this.session.openvidu.sendRequest(
|
if (!!this.session && !!this.stream.streamId) {
|
||||||
'streamPropertyChanged',
|
this.session.openvidu.sendRequest(
|
||||||
{
|
'streamPropertyChanged',
|
||||||
streamId: this.stream.streamId,
|
{
|
||||||
property: 'audioActive',
|
streamId: this.stream.streamId,
|
||||||
newValue: value,
|
property: 'audioActive',
|
||||||
reason: 'publishAudio'
|
newValue: value,
|
||||||
},
|
reason: 'publishAudio'
|
||||||
(error, response) => {
|
},
|
||||||
if (error) {
|
(error, response) => {
|
||||||
console.error("Error sending 'streamPropertyChanged' event", error);
|
if (error) {
|
||||||
} else {
|
console.error("Error sending 'streamPropertyChanged' event", error);
|
||||||
this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this.session, this.stream, 'audioActive', value, !value, 'publishAudio')]);
|
} else {
|
||||||
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, this.stream, 'audioActive', value, !value, 'publishAudio')]);
|
this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this.session, this.stream, 'audioActive', value, !value, 'publishAudio')]);
|
||||||
}
|
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, this.stream, 'audioActive', value, !value, 'publishAudio')]);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
this.stream.audioActive = value;
|
this.stream.audioActive = value;
|
||||||
console.info("'Publisher' has " + (value ? 'published' : 'unpublished') + ' its audio stream');
|
console.info("'Publisher' has " + (value ? 'published' : 'unpublished') + ' its audio stream');
|
||||||
}
|
}
|
||||||
|
@ -132,6 +136,8 @@ export class Publisher extends StreamManager {
|
||||||
*
|
*
|
||||||
* #### Events dispatched
|
* #### Events dispatched
|
||||||
*
|
*
|
||||||
|
* > _Only if `Session.publish(Publisher)` has been called for this Publisher_
|
||||||
|
*
|
||||||
* The [[Session]] object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"videoActive"` and `reason` set to `"publishVideo"`
|
* The [[Session]] object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"videoActive"` and `reason` set to `"publishVideo"`
|
||||||
* The [[Publisher]] object of the local participant will also dispatch the exact same event
|
* The [[Publisher]] object of the local participant will also dispatch the exact same event
|
||||||
*
|
*
|
||||||
|
@ -147,22 +153,24 @@ export class Publisher extends StreamManager {
|
||||||
this.stream.getMediaStream().getVideoTracks().forEach((track) => {
|
this.stream.getMediaStream().getVideoTracks().forEach((track) => {
|
||||||
track.enabled = value;
|
track.enabled = value;
|
||||||
});
|
});
|
||||||
this.session.openvidu.sendRequest(
|
if (!!this.session && !!this.stream.streamId) {
|
||||||
'streamPropertyChanged',
|
this.session.openvidu.sendRequest(
|
||||||
{
|
'streamPropertyChanged',
|
||||||
streamId: this.stream.streamId,
|
{
|
||||||
property: 'videoActive',
|
streamId: this.stream.streamId,
|
||||||
newValue: value,
|
property: 'videoActive',
|
||||||
reason: 'publishVideo'
|
newValue: value,
|
||||||
},
|
reason: 'publishVideo'
|
||||||
(error, response) => {
|
},
|
||||||
if (error) {
|
(error, response) => {
|
||||||
console.error("Error sending 'streamPropertyChanged' event", error);
|
if (error) {
|
||||||
} else {
|
console.error("Error sending 'streamPropertyChanged' event", error);
|
||||||
this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this.session, this.stream, 'videoActive', value, !value, 'publishVideo')]);
|
} else {
|
||||||
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, this.stream, 'videoActive', value, !value, 'publishVideo')]);
|
this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this.session, this.stream, 'videoActive', value, !value, 'publishVideo')]);
|
||||||
}
|
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, this.stream, 'videoActive', value, !value, 'publishVideo')]);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
this.stream.videoActive = value;
|
this.stream.videoActive = value;
|
||||||
console.info("'Publisher' has " + (value ? 'published' : 'unpublished') + ' its video stream');
|
console.info("'Publisher' has " + (value ? 'published' : 'unpublished') + ' its video stream');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue