Fix device selection in pre-join screen for Element Call video rooms (#9321)
* Fix device selection in pre-join screen for Element Call video rooms As per https://github.com/vector-im/element-call/pull/609 * Update unit test * Lint * Hold a media stream while we enumerate device so we can do so reliably. This means we can remove the device fallback labels. * i18n * Remove unnecessary useState * Fix fetching video devices when video muted * Actually fix preview stream code * Fix unit test now fallback is no longer a thing * Test changing devices
This commit is contained in:
parent
eaff7e945c
commit
07a5a1dc6f
7 changed files with 123 additions and 66 deletions
|
@ -50,10 +50,20 @@ export default class MediaDeviceHandler extends EventEmitter {
|
|||
return devices.some(d => Boolean(d.label));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the available audio input/output and video input devices
|
||||
* from the browser: a thin wrapper around mediaDevices.enumerateDevices()
|
||||
* that also returns results by type of devices. Note that this requires
|
||||
* user media permissions and an active stream, otherwise you'll get blank
|
||||
* device labels.
|
||||
*
|
||||
* Once the Permissions API
|
||||
* (https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API)
|
||||
* is ready for primetime, it might help make this simpler.
|
||||
*
|
||||
* @return Promise<IMediaDevices> The available media devices
|
||||
*/
|
||||
public static async getDevices(): Promise<IMediaDevices> {
|
||||
// Only needed for Electron atm, though should work in modern browsers
|
||||
// once permission has been granted to the webapp
|
||||
|
||||
try {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
const output = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue