decentralized-video-chat
decentralized-video-chat copied to clipboard
Changing audio input/output causes page to refresh
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.
I think using the default source should work for now.
But that reload should be easy to prevent :D
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
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.
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.
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
If that's the conclusion, I guess a message to the user would be helpful. Ex: "Microphone was unplugged. Reloading…".
Yeah this shouldn't be a problem :)
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