decentralized-video-chat icon indicating copy to clipboard operation
decentralized-video-chat copied to clipboard

Changing audio input/output causes page to refresh

Open ianramzy opened this issue 4 years ago • 8 comments

Currently, when a user add an audio input or output device the page is refreshed to switch to the system default. An example of this is plugging in headphones. This is the current handler for when a change in audio sources is detected.

// On change media devices refresh page and switch to system default navigator.mediaDevices.ondevicechange = () => window.location.reload();

What would be better is if it would simply swap the stream to use the new system default audio. Or even better have a button to switch between audio inputs/outputs.

ianramzy avatar Apr 11 '20 15:04 ianramzy

I think using the default source should work for now.
But that reload should be easy to prevent :D

Chaphasilor avatar Apr 11 '20 20:04 Chaphasilor

I added the refresh because if you are using headphones as the default audio input, and then you unplug your headphone you lose microphone input. This was a quick fix, there is definitely a more elegant way to do this

ianramzy avatar Apr 12 '20 19:04 ianramzy

We should probably check if there are any inout devices at all and if not, toggle the 'mute' button to reflect that, along with an error message if the user tries to unmute themselves.

Chaphasilor avatar Apr 14 '20 18:04 Chaphasilor

We experimented some issues where the page would refresh by itself. I can't tell for sure if the headphones where disconnecting accidentally of what there reseaons were. However it happens systematically on one side (MacOS latest stable FF) when trying to share screen.

vinyll avatar Apr 16 '20 13:04 vinyll

So I've just looked at this, but I really think fixing this causes more problems than it solves :/ For example, we would need to add and remove tracks, detect what track are available, add new error handlers and status text, etc.

I'd recommend just keeping it the way it is with the reloads, but adding the ability to join a room even if no video input is available and setting some state (video disabled, audio muted, etc.) in localstorage to solve #13

Chaphasilor avatar Apr 16 '20 16:04 Chaphasilor

If that's the conclusion, I guess a message to the user would be helpful. Ex: "Microphone was unplugged. Reloading…".

vinyll avatar Apr 16 '20 16:04 vinyll

Yeah this shouldn't be a problem :)

Chaphasilor avatar Apr 16 '20 17:04 Chaphasilor

I would really like to see auto swapping of input and output. Checkout my branch audio-sucks to see some of what I did for detecting and switching to new tracks

ianramzy avatar Apr 16 '20 23:04 ianramzy