Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching between front and rear cameras requires stopping current track in some scenarios #2021

Open
loganathanav opened this issue Sep 13, 2023 · 4 comments
Assignees
Labels
Android Issues related to Android or Twilio's Android Video SDK iOS Issues related to iOS or Twilio's iOS Video SDK

Comments

@loganathanav
Copy link

I'm using 2.27.0, still the issue exist. Is there any work arounds to overcome this issue.
I'm trying to catch and trying createLocalVideoTrak to have new track. That also not working.

if (isApplePhone) {
room?.localParticipant?.videoTracks.forEach(
(publication) => {
publication.track.stop();
publication.track.restart({ facingMode: 'environment' });
}
);
} else if (isAndroidPhone) {
room?.localParticipant?.videoTracks.forEach(
async (publication) => {
publication.track.stop();
await publication.track.restart({
facingMode: 'environment',
});
}
);
}

Team, please confirm whether we need to use async/await or not inside forEach loop here?
also, do we need to use stop() function in iPhone as well or not required?

Getting error in browser. Provide your suggestions, I'm struck here.

@manjeshbhargav
Copy link
Collaborator

@loganathanav ,

Thanks for writing in with your issue. You don't need to call stop() before calling restart(). Also, it is better to await on the Promise returned by restart(). Hope this helps.

@manjeshbhargav manjeshbhargav self-assigned this Sep 18, 2023
@manjeshbhargav manjeshbhargav added iOS Issues related to iOS or Twilio's iOS Video SDK Android Issues related to Android or Twilio's Android Video SDK labels Sep 18, 2023
@loganathanav
Copy link
Author

Hi @manjeshbhargav,

Thanks for your inputs.
Tried without stop() in Samsung mobiles and when we switch camera it was not switching properly. As workaround I've added stop() before calling restart() for android mobiles.

I've to verify iPhone devices with await on the restart().

All works fine for the first time. Whenever we switch the cameras for the second time in Samsung mobiles getting "DOMException: Could not start video source" error in console and the screen becomes black.

@loganathanav
Copy link
Author

Hi @manjeshbhargav,

Any ideas?

@mrmandarin2002
Copy link

Hey @loganathanav I've run into this issue extensively before. We realized that we were asking for permissions twice. Once through getUserMedia() and another through createLocalTracks(). Didn't realize that createLocalTracks() also asks for permissions. Not sure if related to your issue but hope it helps,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android or Twilio's Android Video SDK iOS Issues related to iOS or Twilio's iOS Video SDK
Projects
None yet
Development

No branches or pull requests

3 participants