Skip to content

Commit d0930e3

Browse files
authored
fix: Fix TypeError in Bidirectional sample on Firefox (#832)
* Fix TypeError in Bidirectional sample on Firefox 108 * fix * fix * fix
1 parent 22a662d commit d0930e3

File tree

7 files changed

+25
-23
lines changed

7 files changed

+25
-23
lines changed

WebApp/client/public/bidirectional/js/main.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ setupButton.addEventListener('click', setUp);
5757
const hangUpButton = document.getElementById('hangUpButton');
5858
hangUpButton.addEventListener('click', hangUp);
5959

60-
window.addEventListener('beforeunload', async () => {
61-
await sendVideo.stop();
62-
}, true);
63-
6460
setupConfig();
6561

6662
async function setupConfig() {
@@ -84,7 +80,6 @@ async function startVideo() {
8480
cameraWidthInput.disabled = true;
8581
cameraHeightInput.disabled = true;
8682
startButton.disabled = true;
87-
setupButton.disabled = false;
8883

8984
let width = 0;
9085
let height = 0;
@@ -98,6 +93,9 @@ async function startVideo() {
9893
}
9994

10095
await sendVideo.startLocalVideo(videoSelect.value, audioSelect.value, width, height);
96+
97+
// enable setup button after initializing local video.
98+
setupButton.disabled = false;
10199
}
102100

103101
async function setUp() {
@@ -127,6 +125,10 @@ async function setUp() {
127125
}
128126
};
129127

128+
window.addEventListener('beforeunload', async () => {
129+
await renderstreaming.stop();
130+
}, true);
131+
130132
await renderstreaming.start();
131133
await renderstreaming.createConnection(connectionId);
132134
}
@@ -280,4 +282,4 @@ function clearStatsMessage() {
280282
remoteVideoStatsDiv.innerHTML = '';
281283
messageDiv.style.display = 'none';
282284
messageDiv.innerHTML = '';
283-
}
285+
}

WebApp/client/public/bidirectional/js/sendvideo.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export class SendVideo {
77
}
88

99
/**
10-
* @param {MediaTrackConstraints} videoSource
11-
* @param {MediaTrackConstraints} audioSource
12-
* @param {number} videoWidth
13-
* @param {number} videoHeight
10+
* @param {MediaTrackConstraints} videoSource
11+
* @param {MediaTrackConstraints} audioSource
12+
* @param {number} videoWidth
13+
* @param {number} videoHeight
1414
*/
1515
async startLocalVideo(videoSource, audioSource, videoWidth, videoHeight) {
1616
try {
@@ -42,7 +42,7 @@ export class SendVideo {
4242
}
4343

4444
/**
45-
* @param {MediaStreamTrack} track
45+
* @param {MediaStreamTrack} track
4646
*/
4747
addRemoteTrack(track) {
4848
if (this.remoteVideo.srcObject == null) {

WebApp/client/src/pointercorrect.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const LetterBoxType = {
55

66
export class PointerCorrector {
77
/**
8-
* @param {Number} videoWidth
8+
* @param {Number} videoWidth
99
* @param {Number} videoHeight
1010
* @param {DOMRect} rect
1111
*/
@@ -63,7 +63,7 @@ export class PointerCorrector {
6363
}
6464

6565
/**
66-
* @param {Number} videoWidth
66+
* @param {Number} videoWidth
6767
* @param {Number} videoHeight
6868
* @param {DOMRect} rect
6969
*/
@@ -99,8 +99,8 @@ export class PointerCorrector {
9999
/**
100100
* Returns rectangle for displaying video with the origin at the left-top of the element.
101101
* Not considered applying CSS like `object-fit`.
102-
* @returns {Object}
103-
*/
102+
* @returns {Object}
103+
*/
104104
get contentRect() {
105105
const letterBoxType = this.letterBoxType;
106106
const letterBoxSize = this.letterBoxSize;
@@ -116,4 +116,4 @@ export class PointerCorrector {
116116
_reset() {
117117
this._contentRect = this.contentRect;
118118
}
119-
}
119+
}

WebApp/client/src/renderstreaming.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class RenderStreaming {
8888

8989
/**
9090
* if not set argument, a generated uuid is used.
91-
* @param {string | null} connectionId
91+
* @param {string | null} connectionId
9292
*/
9393
async createConnection(connectionId) {
9494
this._connectionId = connectionId ? connectionId : uuid4();
@@ -150,15 +150,15 @@ export class RenderStreaming {
150150
}
151151

152152
/**
153-
* @param {string} label
153+
* @param {string} label
154154
* @returns {RTCDataChannel | null}
155155
*/
156156
createDataChannel(label) {
157157
return this._peer.createDataChannel(this._connectionId, label);
158158
}
159159

160160
/**
161-
* @param {MediaStreamTrack} track
161+
* @param {MediaStreamTrack} track
162162
* @returns {RTCRtpSender | null}
163163
*/
164164
addTrack(track) {

WebApp/client/src/signaling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class Signaling extends EventTarget {
7676
break;
7777
default:
7878
break;
79-
}
79+
}
8080
}
8181
await this.sleep(this.interval);
8282
}
@@ -344,4 +344,4 @@ export class WebSocketSignaling extends EventTarget {
344344
Logger.log(sendJson);
345345
this.websocket.send(sendJson);
346346
}
347-
}
347+
}

WebApp/client/src/touchflags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export const TouchFlags =
44
PrimaryTouch: 1 << 4,
55
Tap: 1 << 5,
66
OrphanedPrimaryTouch: 1 << 6,
7-
};
7+
};

WebApp/client/src/touchphase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export const TouchPhase = {
55
Ended: 3,
66
Canceled: 4,
77
Stationary: 5
8-
};
8+
};

0 commit comments

Comments
 (0)