Skip to content

Commit 38e947e

Browse files
committed
Handle camera permission denied
1 parent 28b9159 commit 38e947e

File tree

3 files changed

+66
-10
lines changed

3 files changed

+66
-10
lines changed

public/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@
5757
<div class="permission-denied-text-container">
5858
<div class="permission-denied-text" id="camera_denied">
5959
<p>Please reload and allow camera access to use this app.</p>
60-
<button id="camera-denied-button" class="info-button">
60+
<a
61+
class="permission-denied-button"
62+
href="https://www.deepar.ai/projects"
63+
target="__blank"
64+
>
6165
Discover more
62-
</button>
66+
</a>
6367
</div>
6468
</div>
6569
</div>

public/style.css

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ canvas.deepar {
1111
body {
1212
margin: 0px;
1313
padding: 0px;
14+
font-family: sans-serif;
1415
}
1516

1617
#loading-screen,
1718
#permission-denied-screen,
1819
#permission-denied-background {
1920
background-color: rgb(17 24 39 / 1);
20-
background-image: url("/images/gradient.svg"),
21-
url("/images/bg-grid-dark.svg");
21+
background-image: url("/images/gradient.svg"), url("/images/bg-grid-dark.svg");
2222
background-repeat: no-repeat, repeat;
2323
display: flex;
2424
align-items: center;
@@ -174,4 +174,47 @@ body {
174174
background: rgb(0 98 209 / 1);
175175
height: 100%;
176176
transition: width 5s ease-out;
177-
}
177+
}
178+
179+
/* Permission denied screen */
180+
181+
.permission-denied-text-container {
182+
position: absolute;
183+
left: 50%;
184+
top: 50%;
185+
transform: translateX(-50%) translateY(-50%);
186+
width: 100%;
187+
display: flex;
188+
align-items: center;
189+
justify-content: center;
190+
flex-direction: column;
191+
text-align: center;
192+
}
193+
194+
.permission-denied-text {
195+
width: 400px;
196+
max-width: 95%;
197+
font-size: 16px;
198+
line-height: 1.2;
199+
color: #fff;
200+
}
201+
202+
.permission-denied-button {
203+
margin-top: 20px;
204+
padding: 10px 20px;
205+
border-radius: 4px;
206+
background-color: #fff;
207+
color: #000;
208+
font-size: 16px;
209+
font-weight: 500;
210+
cursor: pointer;
211+
transition: background-color 0.2s ease;
212+
border: none;
213+
display: inline-block;
214+
text-decoration: none;
215+
width: fit-content;
216+
217+
&:hover {
218+
background-color: #eaeaea;
219+
}
220+
}

src/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,21 @@ console.log("Deepar version: " + deepar.version);
3737
"effects/Fire_Effect.deepar",
3838
];
3939

40+
let deepAR = null;
41+
4042
// Initialize DeepAR with an effect file.
41-
const deepAR = await deepar.initialize({
42-
licenseKey: "your_license_key_goes_here",
43-
canvas,
44-
effect: effectList[0],
45-
});
43+
try {
44+
deepAR = await deepar.initialize({
45+
licenseKey: "your_license_key_goes_here",
46+
canvas,
47+
effect: effectList[0],
48+
});
49+
} catch (error) {
50+
console.error(error);
51+
document.getElementById("loading-screen").style.display = "none";
52+
document.getElementById("permission-denied-screen").style.display = "block";
53+
return;
54+
}
4655

4756
var resizeCanvas = function () {
4857
const canvas = document.getElementById("deepar-canvas");

0 commit comments

Comments
 (0)