fix: 🐛 play does not exist on type HTMLElement

I explicitly cast the document.getElementById('voice-preview') expression to the HTMLMediaElement type, which includes the play method.
main
jfraile 2023-03-08 14:18:13 +01:00
parent 16e5ae4d23
commit 2dd120843e
1 changed files with 1 additions and 1 deletions

View File

@ -222,7 +222,7 @@ export default function SettingsScreen(props: SettingsScreenProps) {
<audio controls style={{ display: 'none' }} id="voice-preview" key={context.voice.id}> <audio controls style={{ display: 'none' }} id="voice-preview" key={context.voice.id}>
<source src={voices.find(v => v.voice_id === context.voice.id)?.preview_url} type="audio/mpeg" /> <source src={voices.find(v => v.voice_id === context.voice.id)?.preview_url} type="audio/mpeg" />
</audio> </audio>
<Button onClick={() => document.getElementById('voice-preview')?.play()} variant='light' compact style={{ marginTop: '1rem' }}> <Button onClick={() => (document.getElementById('voice-preview') as HTMLMediaElement)?.play()} variant='light' compact style={{ marginTop: '1rem' }}>
<i className='fa fa-headphones' /> <i className='fa fa-headphones' />
<span>Preview voice</span> <span>Preview voice</span>
</Button> </Button>