|
1 | 1 | import { useEffect, useState } from 'react'; |
2 | | -import BrowserAdapter from '../services/browser.adapter'; |
3 | | -import ChromeService from '../services/chome.service'; |
4 | | -import FirefoxService from '../services/firefox.service'; |
5 | 2 | import { detectBrowser } from '../utils/detectBrowser'; |
6 | | - |
7 | | -export default function PopPage() { |
8 | | - const [browserAdapter, setBrowserAdapter] = useState<BrowserAdapter<BrowserTab> | null>(null); |
| 3 | +import { ChromeService, FirefoxService, TranscriptService } from '../services'; |
| 4 | +function App() { |
| 5 | + const [transcriptService, setTranscriptService] = useState<TranscriptService | null>(null); |
| 6 | + const [textTranscription, setTextTranscript] = useState<string | null | undefined>(null); |
9 | 7 |
|
10 | 8 | useEffect(() => { |
11 | 9 | const browser = detectBrowser(); |
12 | 10 | if (browser === 'chrome') { |
13 | | - setBrowserAdapter(new ChromeService()); // Chrome, Edge, Brave |
| 11 | + setTranscriptService(new TranscriptService(new ChromeService())); // Chrome, Edge, Brave |
14 | 12 | } else if (browser === 'firefox') { |
15 | | - setBrowserAdapter(new FirefoxService()); // Firefox |
| 13 | + setTranscriptService(new TranscriptService(new FirefoxService())); |
16 | 14 | } else { |
17 | 15 | console.warn('Navegador no soportado o desconocido'); |
18 | 16 | } |
19 | 17 | }, []); |
20 | 18 |
|
21 | 19 | const onclick = async () => { |
22 | | - if (browserAdapter) { |
23 | | - await browserAdapter.executeScript(() => { |
24 | | - console.log('Hello from the browser!'); |
25 | | - }); |
| 20 | + if (transcriptService) { |
| 21 | + const text = await transcriptService.textTranscriptionVideo(); |
| 22 | + console.log(text); |
| 23 | + setTextTranscript(text); |
26 | 24 | } |
27 | 25 | }; |
| 26 | + |
28 | 27 | return ( |
29 | 28 | <> |
30 | | - <button onClick={onclick}>Click me Hello</button> |
| 29 | + <button onClick={onclick}>Get Transcript</button> |
| 30 | + {textTranscription && <p>{textTranscription}</p>} |
31 | 31 | </> |
32 | 32 | ); |
33 | 33 | } |
| 34 | + |
| 35 | +export default App; |
0 commit comments