rtc

minimal webrtc client
git clone git://ce9e.org/rtc

commit
94492af9105b9296fc7e45355a9469dc304caf30
parent
f1751a6a8ac6f83dac64dfe6ec29506c074d0691
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-03-31 20:40
detect unavailable devices at the start

Diffstat

M www/common.css 7 +++++++
M www/rtc/index.html 4 ++--
M www/rtc/rtc.js 10 ++++++++++

3 files changed, 19 insertions, 2 deletions


diff --git a/www/common.css b/www/common.css

@@ -43,6 +43,13 @@ button:active,
   43    43 	border-color: #2b4d80;
   44    44 	background: #2b4d80;
   45    45 }
   -1    46 button:disabled,
   -1    47 .toggle :disabled + .btn {
   -1    48 	border-color: #777;
   -1    49 	background: #777;
   -1    50 	color: #ccc;
   -1    51 	cursor: default;
   -1    52 }
   46    53 
   47    54 .toggle .btn::before {
   48    55 	content: "";

diff --git a/www/rtc/index.html b/www/rtc/index.html

@@ -15,11 +15,11 @@
   15    15 		</div>
   16    16 		<div class="rtc-controls">
   17    17 			<label class="toggle">
   18    -1 				<input type="checkbox" name="audio" autocomplete="off">
   -1    18 				<input type="checkbox" name="audio" autocomplete="off" disabled>
   19    19 				<span class="btn">Audio</span>
   20    20 			</label>
   21    21 			<label class="toggle">
   22    -1 				<input type="checkbox" name="video" autocomplete="off">
   -1    22 				<input type="checkbox" name="video" autocomplete="off" disabled>
   23    23 				<span class="btn">Video</span>
   24    24 			</label>
   25    25 			<label class="toggle">

diff --git a/www/rtc/rtc.js b/www/rtc/rtc.js

@@ -222,6 +222,16 @@
  222   222 		}
  223   223 	});
  224   224 
   -1   225 	navigator.mediaDevices.enumerateDevices().then(devices => {
   -1   226 		devices.forEach(device => {
   -1   227 			if (device.kind === 'audioinput') {
   -1   228 				document.querySelector('.rtc-controls [name="audio"]').disabled = false;
   -1   229 			} else if (device.kind === 'videoinput') {
   -1   230 				document.querySelector('.rtc-controls [name="video"]').disabled = false;
   -1   231 			}
   -1   232 		});
   -1   233 	});
   -1   234 
  225   235 	updateIdealColumns();
  226   236 	window.addEventListener('resize', updateIdealColumns);
  227   237 })();