Spaces:
Running
Running
Create select_back_camera.js
Browse files- select_back_camera.js +18 -0
select_back_camera.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
window.addEventListener('load', (event) => {
|
2 |
+
// Wait for Gradio interface to fully load
|
3 |
+
const gradioAppLoaded = setInterval(() => {
|
4 |
+
const webcamButton = document.querySelector('button[aria-label="select input source"]');
|
5 |
+
if (webcamButton) {
|
6 |
+
clearInterval(gradioAppLoaded);
|
7 |
+
webcamButton.click();
|
8 |
+
setTimeout(() => {
|
9 |
+
const backCameraOption = Array.from(document.querySelectorAll('select option')).find(option => option.text.toLowerCase().includes('back'));
|
10 |
+
if (backCameraOption) {
|
11 |
+
backCameraOption.selected = true;
|
12 |
+
const event = new Event('change', { bubbles: true });
|
13 |
+
backCameraOption.parentElement.dispatchEvent(event);
|
14 |
+
}
|
15 |
+
}, 500); // Adjust timeout as necessary to ensure dropdown is populated
|
16 |
+
}
|
17 |
+
}, 1000);
|
18 |
+
});
|