shreyask commited on
Commit
7c9743c
·
verified ·
1 Parent(s): 52709db

feat: add more ability to get started

Browse files
src/components/InputSourceDialog.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useState, useEffect, useCallback, useMemo } from "react";
2
  import GlassContainer from "./GlassContainer";
3
  import GlassButton from "./GlassButton";
4
  import { GLASS_EFFECTS } from "../constants";
@@ -137,22 +137,22 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
137
 
138
  // Create a video element that will be used directly instead of canvas stream
139
  const videoUrl = URL.createObjectURL(file);
140
-
141
  // Create a mock stream that signals this is a file source
142
  const canvas = document.createElement('canvas');
143
  canvas.width = 1;
144
  canvas.height = 1;
145
  const mockStream = canvas.captureStream(1);
146
-
147
  // Store the video file URL on the stream for later use
148
  (mockStream as any).videoFileUrl = videoUrl;
149
-
150
  onSourceSelected(mockStream, 'file');
151
  }, [onSourceSelected]);
152
 
153
  const renderIcon = (source: InputSource) => {
154
  const iconClass = "w-8 h-8";
155
-
156
  switch (source) {
157
  case 'webcam':
158
  return (
@@ -183,8 +183,8 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
183
  <div className="p-8 text-center space-y-6">
184
  <div className="animate-spin rounded-full h-16 w-16 border-4 border-blue-500 border-t-transparent mx-auto" />
185
  <h2 className="text-2xl font-bold text-gray-100">
186
- {selectedSource === 'webcam' ? 'Requesting Camera Access' :
187
- selectedSource === 'screen' ? 'Requesting Screen Access' :
188
  'Loading Video File'}
189
  </h2>
190
  <p className="text-gray-400">Please allow access in your browser to continue...</p>
@@ -201,10 +201,10 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
201
  <div className="p-8 text-center space-y-6">
202
  <h2 className="text-3xl font-bold text-gray-100">Choose Input Source</h2>
203
  <p className="text-gray-400">Select how you want to provide video for captioning</p>
204
-
205
  <div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-8">
206
  {/* Webcam Option */}
207
- <GlassContainer
208
  className="rounded-2xl p-6 cursor-pointer hover:scale-105 transition-transform duration-200"
209
  bgColor={GLASS_EFFECTS.COLORS.DEFAULT_BG}
210
  onClick={() => {
@@ -222,7 +222,7 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
222
  </GlassContainer>
223
 
224
  {/* Screen Recording Option */}
225
- <GlassContainer
226
  className="rounded-2xl p-6 cursor-pointer hover:scale-105 transition-transform duration-200"
227
  bgColor={GLASS_EFFECTS.COLORS.DEFAULT_BG}
228
  onClick={() => {
@@ -240,7 +240,7 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
240
  </GlassContainer>
241
 
242
  {/* Video File Option */}
243
- <GlassContainer
244
  className="rounded-2xl p-6 cursor-pointer hover:scale-105 transition-transform duration-200"
245
  bgColor={GLASS_EFFECTS.COLORS.DEFAULT_BG}
246
  >
@@ -264,7 +264,7 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
264
 
265
  {/* Error Display */}
266
  {error && (
267
- <GlassContainer
268
  className="rounded-2xl shadow-2xl"
269
  bgColor={GLASS_EFFECTS.COLORS.ERROR_BG}
270
  >
@@ -276,7 +276,7 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
276
  </div>
277
  <h3 className="text-xl font-bold text-gray-100 mb-2">Access Failed</h3>
278
  <p className="text-red-400 mb-4">{error.message}</p>
279
-
280
  <GlassButton
281
  onClick={() => {
282
  setError(null);
@@ -292,4 +292,4 @@ export default function InputSourceDialog({ onSourceSelected }: InputSourceDialo
292
  </div>
293
  </div>
294
  );
295
- }
 
1
+ import { useState, useCallback } from "react";
2
  import GlassContainer from "./GlassContainer";
3
  import GlassButton from "./GlassButton";
4
  import { GLASS_EFFECTS } from "../constants";
 
137
 
138
  // Create a video element that will be used directly instead of canvas stream
139
  const videoUrl = URL.createObjectURL(file);
140
+
141
  // Create a mock stream that signals this is a file source
142
  const canvas = document.createElement('canvas');
143
  canvas.width = 1;
144
  canvas.height = 1;
145
  const mockStream = canvas.captureStream(1);
146
+
147
  // Store the video file URL on the stream for later use
148
  (mockStream as any).videoFileUrl = videoUrl;
149
+
150
  onSourceSelected(mockStream, 'file');
151
  }, [onSourceSelected]);
152
 
153
  const renderIcon = (source: InputSource) => {
154
  const iconClass = "w-8 h-8";
155
+
156
  switch (source) {
157
  case 'webcam':
158
  return (
 
183
  <div className="p-8 text-center space-y-6">
184
  <div className="animate-spin rounded-full h-16 w-16 border-4 border-blue-500 border-t-transparent mx-auto" />
185
  <h2 className="text-2xl font-bold text-gray-100">
186
+ {selectedSource === 'webcam' ? 'Requesting Camera Access' :
187
+ selectedSource === 'screen' ? 'Requesting Screen Access' :
188
  'Loading Video File'}
189
  </h2>
190
  <p className="text-gray-400">Please allow access in your browser to continue...</p>
 
201
  <div className="p-8 text-center space-y-6">
202
  <h2 className="text-3xl font-bold text-gray-100">Choose Input Source</h2>
203
  <p className="text-gray-400">Select how you want to provide video for captioning</p>
204
+
205
  <div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-8">
206
  {/* Webcam Option */}
207
+ <GlassContainer
208
  className="rounded-2xl p-6 cursor-pointer hover:scale-105 transition-transform duration-200"
209
  bgColor={GLASS_EFFECTS.COLORS.DEFAULT_BG}
210
  onClick={() => {
 
222
  </GlassContainer>
223
 
224
  {/* Screen Recording Option */}
225
+ <GlassContainer
226
  className="rounded-2xl p-6 cursor-pointer hover:scale-105 transition-transform duration-200"
227
  bgColor={GLASS_EFFECTS.COLORS.DEFAULT_BG}
228
  onClick={() => {
 
240
  </GlassContainer>
241
 
242
  {/* Video File Option */}
243
+ <GlassContainer
244
  className="rounded-2xl p-6 cursor-pointer hover:scale-105 transition-transform duration-200"
245
  bgColor={GLASS_EFFECTS.COLORS.DEFAULT_BG}
246
  >
 
264
 
265
  {/* Error Display */}
266
  {error && (
267
+ <GlassContainer
268
  className="rounded-2xl shadow-2xl"
269
  bgColor={GLASS_EFFECTS.COLORS.ERROR_BG}
270
  >
 
276
  </div>
277
  <h3 className="text-xl font-bold text-gray-100 mb-2">Access Failed</h3>
278
  <p className="text-red-400 mb-4">{error.message}</p>
279
+
280
  <GlassButton
281
  onClick={() => {
282
  setError(null);
 
292
  </div>
293
  </div>
294
  );
295
+ }
src/components/WelcomeScreen.tsx CHANGED
@@ -1,7 +1,6 @@
1
  import HfIcon from "./HfIcon";
2
  import GlassContainer from "./GlassContainer";
3
  import GlassButton from "./GlassButton";
4
- import { GLASS_EFFECTS } from "../constants";
5
 
6
  interface WelcomeScreenProps {
7
  onStart: () => void;
 
1
  import HfIcon from "./HfIcon";
2
  import GlassContainer from "./GlassContainer";
3
  import GlassButton from "./GlassButton";
 
4
 
5
  interface WelcomeScreenProps {
6
  onStart: () => void;