Skip to content

Commit 03970eb

Browse files
authored
Merge pull request #104 from AgoraIO-Community/revert-94-main
Revert "Unmuting now publish track if not already publishing"
2 parents 9ea2d09 + 8963816 commit 03970eb

File tree

2 files changed

+32
-59
lines changed

2 files changed

+32
-59
lines changed

Assets/WebGLTemplates/AgoraTemplate/AgoraWebSDK/libs/agorachannel.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class AgoraChannel {
206206
const vad = 0;
207207
const channel_str = this.channelId;
208208
result.forEach(function (volume, index) {
209-
//console.log(`${index} UID ${volume.uid} Level ${volume.level}`);
209+
console.log(`${index} UID ${volume.uid} Level ${volume.level}`);
210210

211211
if (volume.level > total) {
212212
total = volume.level;
@@ -280,8 +280,9 @@ class AgoraChannel {
280280
if (this.client_role === 1 && this.videoEnabled) {
281281
await this.setupLocalVideoTrack();
282282
if (localTracks.videoTrack != undefined) {
283-
await this.client.publish(localTracks.videoTrack);
283+
localTracks.videoTrack.play("local-player");
284284
}
285+
await this.client.publish(localTracks.videoTrack);
285286
this.is_publishing = true;
286287
}
287288

@@ -607,14 +608,8 @@ class AgoraChannel {
607608
await this.client.unpublish(localTracks.audioTrack);
608609
}
609610
} else {
610-
if(localTracks.audioTrack) {
611+
if (localTracks.audioTrack) {
611612
await this.client.publish(localTracks.audioTrack);
612-
} else {
613-
await this.setupLocalAudioTrack();
614-
if (localTracks.audioTrack != undefined) {
615-
await this.client.publish(localTracks.audioTrack);
616-
}
617-
this.is_publishing = true;
618613
}
619614
}
620615
this.audioEnabled = !mute;
@@ -634,15 +629,16 @@ class AgoraChannel {
634629
AgoraRTC.createCameraVideoTrack(),
635630
]);
636631
localTracks.videoTrack.play("local-player");
637-
this.is_publishing = true;
638-
await this.client.publish(localTracks.videoTrack);
632+
if (this.is_publishing) {
633+
await this.client.publish(localTracks.videoTrack);
634+
}
639635
}
640636
this.videoEnabled = !mute;
641637
}
642638
}
643-
644639
muteRemoteAudioStream(uid, mute) {
645640
Object.keys(this.remoteUsers).forEach((uid2) => {
641+
646642
if (uid2 == uid) {
647643
if (mute == true) {
648644
this.unsubscribe(this.remoteUsers[uid], "audio");

Assets/WebGLTemplates/AgoraTemplate/AgoraWebSDK/libs/clientmanager.js

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -435,17 +435,34 @@ class ClientManager {
435435
// Help function for JoinChannel
436436
async processJoinChannelAVTrack() {
437437
if (this.videoEnabled && this.isHosting()) {
438-
await this.setupLocalVideoTrack();
438+
[localTracks.videoTrack] = await Promise.all([
439+
AgoraRTC.createCameraVideoTrack(this._customVideoConfiguration)
440+
]);
441+
currentVideoDevice = wrapper.getCameraDeviceIdFromDeviceName(
442+
localTracks.videoTrack._deviceName
443+
);
439444
}
440445

441446
if (this.audioEnabled && this.isHosting()) {
442-
await this.setupLocalAudioTrack();
447+
[localTracks.audioTrack] = await Promise.all([
448+
AgoraRTC.createMicrophoneAudioTrack()
449+
]);
450+
currentAudioDevice = wrapper.getMicrophoneDeviceIdFromDeviceName(
451+
localTracks.audioTrack._deviceName
452+
);
443453
}
444-
445454
event_manager.raiseGetCurrentVideoDevice();
446455
event_manager.raiseGetCurrentAudioDevice();
447456
event_manager.raiseGetCurrentPlayBackDevice();
448457

458+
// videoTrack exists implies videoEnabled
459+
if (localTracks.videoTrack) {
460+
localTracks.videoTrack.play("local-player", {
461+
fit: "cover",
462+
mirror: mlocal,
463+
});
464+
}
465+
449466
$("#local-player-name").text(`localVideo(${this.options.uid})`);
450467
if (this.isHosting() && this._inChannel) {
451468
for (var trackName in localTracks) {
@@ -457,32 +474,6 @@ class ClientManager {
457474
}
458475
}
459476

460-
async setupLocalVideoTrack(){
461-
[localTracks.videoTrack] = await Promise.all([
462-
AgoraRTC.createCameraVideoTrack(this._customVideoConfiguration)
463-
]);
464-
currentVideoDevice = wrapper.getCameraDeviceIdFromDeviceName(
465-
localTracks.videoTrack._deviceName
466-
);
467-
468-
// videoTrack exists implies videoEnabled
469-
if (localTracks.videoTrack) {
470-
localTracks.videoTrack.play("local-player", {
471-
fit: "cover",
472-
mirror: mlocal,
473-
});
474-
}
475-
}
476-
477-
async setupLocalAudioTrack(){
478-
[localTracks.audioTrack] = await Promise.all([
479-
AgoraRTC.createMicrophoneAudioTrack()
480-
]);
481-
currentAudioDevice = wrapper.getMicrophoneDeviceIdFromDeviceName(
482-
localTracks.audioTrack._deviceName
483-
);
484-
}
485-
486477
async setClientRole(role, optionLevel) {
487478
if (this.client) {
488479
var wasAudience = (this.client_role == 2);
@@ -524,22 +515,12 @@ class ClientManager {
524515
// can still be on
525516
// if wanting both off, call disableLocalVideo
526517
async muteLocalVideoStream(mute) {
527-
if (this.client && !this.is_screensharing) {
518+
if (localTracks.videoTrack) {
528519
if (mute) {
529-
if (localTracks.videoTrack) {
530-
localTracks.videoTrack.stop();
531-
localTracks.videoTrack.close();
532-
await this.client.unpublish(localTracks.videoTrack);
533-
}
520+
await this.client.unpublish(localTracks.videoTrack);
534521
} else {
535-
if (localTracks.videoTrack) {
536-
await this.client.publish(localTracks.videoTrack);
537-
} else {
538-
await this.setupLocalVideoTrack();
539-
await this.client.publish(localTracks.videoTrack);
540-
}
522+
await this.client.publish(localTracks.videoTrack);
541523
}
542-
this.videoEnabled = !mute;
543524
}
544525
}
545526

@@ -551,12 +532,8 @@ class ClientManager {
551532
} else {
552533
if (localTracks.audioTrack) {
553534
await this.client.publish(localTracks.audioTrack);
554-
} else {
555-
await this.setupLocalAudioTrack();
556-
await this.client.publish(localTracks.audioTrack);
557535
}
558536
}
559-
this.audioEnabled = !mute;
560537
}
561538

562539
async enableLocalVideo(enabled) {
@@ -1026,4 +1003,4 @@ class ClientManager {
10261003
event_manager.raiseOnClientVideoSizeChanged(uid, width, height);
10271004
});
10281005
}
1029-
}
1006+
}

0 commit comments

Comments
 (0)