Skip to content

Commit 579f88d

Browse files
authored
fix: Add autocomplete attribute into input elements to avoid issue of "disabled" attribute on Firefox (#834)
* wip (cherry picked from commit f73792b9c689bac448c1a85ce4db2b21ccdf5187) * set autocomplete attribute for firefox * add null check * fix
1 parent d0930e3 commit 579f88d

File tree

7 files changed

+40
-25
lines changed

7 files changed

+40
-25
lines changed

WebApp/client/public/bidirectional/index.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@ <h1>Bidirectional Sample</h1>
1616
<div id="warning" hidden=true></div>
1717

1818
<div id="select">
19-
<label for="videoSource">Video source: </label><select id="videoSource"></select>
20-
<label for="audioSource">Audio source: </label><select id="audioSource"></select>
19+
<label for="videoSource">Video source: </label>
20+
<select id="videoSource" autocomplete="off"></select>
21+
<label for="audioSource">Audio source: </label>
22+
<select id="audioSource" autocomplete="off"></select>
2123
</div>
2224

2325
<div id="resolutionSelect">
24-
<label for="videoResolution">Video resolution: </label><select id="videoResolution"></select>
26+
<label for="videoResolution">Video resolution: </label><select id="videoResolution" autocomplete="off"></select>
2527
</div>
2628
<div id="resolutionInput">
27-
<label for="cameraWidth">Camera width:</label><input id="cameraWidth" type="number" min="0" max="4096" disabled>
28-
<label for="cameraHeight">Camera height:</label><input id="cameraHeight" type="number" min="0" max="4096"
29-
disabled>
29+
<label for="cameraWidth">Camera width:</label><input id="cameraWidth" type="number" min="0" max="4096" autocomplete="off" disabled>
30+
<label for="cameraHeight">Camera height:</label><input id="cameraHeight" type="number" min="0" max="4096" autocomplete="off" disabled>
3031
</div>
3132

3233
<div id="buttons">
33-
<button type="button" id="startVideoButton">Start Video</button>
34-
<button type="button" id="setUpButton" disabled>Set Up</button>
35-
<button type="button" id="hangUpButton" disabled>Hang Up</button>
34+
<button type="button" id="startVideoButton" autocomplete="off">Start Video</button>
35+
<button type="button" id="setUpButton" autocomplete="off" disabled>Set Up</button>
36+
<button type="button" id="hangUpButton" autocomplete="off" disabled>Hang Up</button>
3637
</div>
3738

3839
<div id="preview">
@@ -54,7 +55,7 @@ <h2>Remote</h2>
5455
</div>
5556
<div class="box">
5657
<span>Codec preferences:</span>
57-
<select id="codecPreferences" disabled>
58+
<select id="codecPreferences" autocomplete="off" disabled>
5859
<option selected value="">Default</option>
5960
</select>
6061
</div>
@@ -80,4 +81,4 @@ <h2>Remote</h2>
8081

8182
</body>
8283

83-
</html>
84+
</html>

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

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

60+
window.addEventListener('beforeunload', async () => {
61+
if(!renderstreaming)
62+
return;
63+
await renderstreaming.stop();
64+
}, true);
65+
6066
setupConfig();
6167

6268
async function setupConfig() {
@@ -110,7 +116,7 @@ async function setUp() {
110116
renderstreaming.onConnect = () => {
111117
const tracks = sendVideo.getLocalTracks();
112118
for (const track of tracks) {
113-
renderstreaming.addTrack(track);
119+
renderstreaming.addTransceiver(track, { direction: 'sendonly' });
114120
}
115121
setCodecPreferences();
116122
showStatsMessage();
@@ -125,10 +131,6 @@ async function setUp() {
125131
}
126132
};
127133

128-
window.addEventListener('beforeunload', async () => {
129-
await renderstreaming.stop();
130-
}, true);
131-
132134
await renderstreaming.start();
133135
await renderstreaming.createConnection(connectionId);
134136
}

WebApp/client/public/multiplay/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ <h1>Multiplay Sample</h1>
2020

2121
<div class="box">
2222
<span>Codec preferences:</span>
23-
<select id="codecPreferences" disabled>
23+
<select id="codecPreferences" autocomplete="off" disabled>
2424
<option selected value="">Default</option>
2525
</select>
2626
</div>
2727

2828
<div class="box">
2929
<span>Lock Cursor to Player:</span>
30-
<input type="checkbox" id="lockMouseCheck">
30+
<input type="checkbox" id="lockMouseCheck" autocomplete="off" />
3131
</div>
3232

3333
<p>
@@ -51,4 +51,4 @@ <h1>Multiplay Sample</h1>
5151

5252
</body>
5353

54-
</html>
54+
</html>

WebApp/client/public/multiplay/js/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ window.addEventListener('resize', function () {
3939
}, true);
4040

4141
window.addEventListener('beforeunload', async () => {
42+
if(!renderstreaming)
43+
return;
4244
await renderstreaming.stop();
4345
}, true);
4446

@@ -198,4 +200,4 @@ function clearStatsMessage() {
198200
intervalId = null;
199201
messageDiv.style.display = 'none';
200202
messageDiv.innerHTML = '';
201-
}
203+
}

WebApp/client/public/receiver/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ <h1>Receiver Sample</h1>
2020

2121
<div class="box">
2222
<span>Codec preferences:</span>
23-
<select id="codecPreferences" disabled>
23+
<select id="codecPreferences" autocomplete="off" disabled>
2424
<option selected value="">Default</option>
2525
</select>
2626
</div>
2727

2828
<div class="box">
2929
<span>Lock Cursor to Player:</span>
30-
<input type="checkbox" id="lockMouseCheck">
30+
<input type="checkbox" id="lockMouseCheck" autocomplete="off" />
3131
</div>
3232

3333
<p>
34-
For more information about sample, see
34+
For more information about sample, see
3535
<a href="https://docs.unity3d.com/Packages/[email protected]/manual/sample-broadcast.html">Broadcast sample</a> document page.
3636
</p>
3737

@@ -51,4 +51,4 @@ <h1>Receiver Sample</h1>
5151

5252
</body>
5353

54-
</html>
54+
</html>

WebApp/client/src/peer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class Peer extends EventTarget {
180180
try {
181181
await this.pc.addIceCandidate(candidate);
182182
} catch (e) {
183-
if (this.pc && !this.ignoreOffer)
183+
if (this.pc && !this.ignoreOffer)
184184
this.warn(`${this.pc} this candidate can't accept current signaling state ${this.pc.signalingState}.`);
185185
}
186186
}

WebApp/client/src/renderstreaming.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ export class RenderStreaming {
165165
return this._peer.addTrack(this._connectionId, track);
166166
}
167167

168+
/**
169+
* @param {MediaStreamTrack | string} trackOrKind
170+
* @param {RTCRtpTransceiverInit | null} init
171+
* @returns {RTCRtpTransceiver | null}
172+
*/
173+
addTransceiver(trackOrKind, init) {
174+
return this._peer.addTransceiver(this._connectionId, trackOrKind, init);
175+
}
176+
177+
168178
/**
169179
* @returns {RTCRtpTransceiver[] | null}
170180
*/

0 commit comments

Comments
 (0)