mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: remote Stream status bug fix (videoActive and audioActive)
parent
7a48d52958
commit
12f8f8ecd3
|
@ -283,10 +283,12 @@ export class Publisher extends StreamManager {
|
|||
|
||||
// Apply PublisherProperties.publishAudio and PublisherProperties.publishVideo
|
||||
if (!!mediaStream.getAudioTracks()[0]) {
|
||||
mediaStream.getAudioTracks()[0].enabled = !!this.stream.outboundStreamOpts.publisherProperties.publishAudio;
|
||||
const enabled = (this.stream.audioActive !== undefined && this.stream.audioActive !== null) ? this.stream.audioActive : !!this.stream.outboundStreamOpts.publisherProperties.publishAudio;
|
||||
mediaStream.getAudioTracks()[0].enabled = enabled;
|
||||
}
|
||||
if (!!mediaStream.getVideoTracks()[0]) {
|
||||
mediaStream.getVideoTracks()[0].enabled = !!this.stream.outboundStreamOpts.publisherProperties.publishVideo;
|
||||
const enabled = (this.stream.videoActive !== undefined && this.stream.videoActive !== null) ? this.stream.videoActive : !!this.stream.outboundStreamOpts.publisherProperties.publishVideo;
|
||||
mediaStream.getVideoTracks()[0].enabled = enabled;
|
||||
}
|
||||
|
||||
this.videoReference = document.createElement('video');
|
||||
|
@ -507,14 +509,6 @@ export class Publisher extends StreamManager {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
updateSession(session: Session): void {
|
||||
this.session = session;
|
||||
this.stream.session = session;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
|
|
|
@ -571,6 +571,7 @@ export class Session implements EventDispatcher {
|
|||
* See [[EventDispatcher.once]]
|
||||
*/
|
||||
once(type: string, handler: (event: SessionDisconnectedEvent | SignalEvent | StreamEvent | ConnectionEvent | PublisherSpeakingEvent | RecordingEvent) => void): Session {
|
||||
|
||||
this.ee.once(type, event => {
|
||||
if (event) {
|
||||
console.info("Event '" + type + "' triggered by 'Session'", event);
|
||||
|
@ -582,7 +583,6 @@ export class Session implements EventDispatcher {
|
|||
|
||||
if (type === 'publisherStartSpeaking' || type === 'publisherStopSpeaking') {
|
||||
this.speakingEventsEnabled = true;
|
||||
|
||||
// If there are already available remote streams, enable hark in all of them
|
||||
for (const connectionId in this.remoteConnections) {
|
||||
const str = this.remoteConnections[connectionId].stream;
|
||||
|
|
|
@ -350,19 +350,19 @@ export class StreamManager implements EventDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
this.videos.slice().reverse().forEach((streamManagerVideo, index, videos) => {
|
||||
this.videos.forEach(streamManagerVideo => {
|
||||
// Remove oncanplay event listener (only OpenVidu browser one, not the user ones)
|
||||
streamManagerVideo.video.removeEventListener('canplay', this.canPlayListener);
|
||||
if (!!streamManagerVideo.targetElement) {
|
||||
// Only remove videos created by OpenVidu Browser (those generated by passing a valid targetElement in OpenVidu.initPublisher and Session.subscribe
|
||||
// or those created by StreamManager.createVideoElement). These are also the videos that triggered a videoElementCreated event
|
||||
// Only remove from DOM videos created by OpenVidu Browser (those generated by passing a valid targetElement in OpenVidu.initPublisher
|
||||
// and Session.subscribe or those created by StreamManager.createVideoElement). All this videos triggered a videoElementCreated event
|
||||
streamManagerVideo.video.parentNode!.removeChild(streamManagerVideo.video);
|
||||
this.ee.emitEvent('videoElementDestroyed', [new VideoElementEvent(streamManagerVideo.video, this, 'videoElementDestroyed')]);
|
||||
this.videos.splice(videos.length - 1 - index, 1);
|
||||
} else {
|
||||
// Remove srcObject in all videos managed by the user
|
||||
streamManagerVideo.video.srcObject = null;
|
||||
}
|
||||
// Remove srcObject from the video
|
||||
streamManagerVideo.video.srcObject = null;
|
||||
// Remove from collection of videos every video managed by OpenVidu Browser
|
||||
this.videos.filter(v => !v.targetElement);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import { Session } from '../..';
|
|||
* - `publisherStopSpeaking`: dispatched by [[Session]]
|
||||
*
|
||||
* More information:
|
||||
* - This events will only be triggered for **remote streams that have audio tracks**
|
||||
* - This events will only be triggered for **remote streams that have audio tracks** ([[Stream.hasAudio]] must be true)
|
||||
* - Both events share the same lifecycle. That means that you can subscribe to only one of them if you want, but if you call `Session.off('publisherStopSpeaking')`,
|
||||
* keep in mind that this will also internally remove any 'publisherStartSpeaking' event
|
||||
* - You can further configure how the events are dispatched by setting property `publisherSpeakingEventsOptions` in the call of [[OpenVidu.setAdvancedConfiguration]]
|
||||
|
|
|
@ -223,7 +223,7 @@ function WebSocketWithReconnection(config) {
|
|||
|
||||
this.reconnectWs = function() {
|
||||
Logger.debug("reconnectWs");
|
||||
reconnectToSameUri(MAX_RETRIES, 1, wsUri);
|
||||
reconnectToSameUri(MAX_RETRIES, 1);
|
||||
};
|
||||
|
||||
this.send = function(message) {
|
||||
|
|
Loading…
Reference in New Issue