audio load

Signed-off-by: ale <ale@manalejandro.com>
This commit is contained in:
ale 2025-05-20 01:56:54 +02:00
parent 0ff53b190d
commit 51b6250760
Signed by: ale
GPG Key ID: 244A9C4DAB1C0C81

View File

@ -50,7 +50,11 @@ const App = () => {
}).catch(err => { }).catch(err => {
console.error('Error fetching data: ' + err.message) console.error('Error fetching data: ' + err.message)
}) })
} },
play = useCallback(async () => {
setMuted(false)
await audioElmRef.current?.play()
}, [audioElmRef.current])
useEffect(() => { useEffect(() => {
if (json?.media?.track[0] && bounce.search(json?.media?.track[0].Title) === -1) { if (json?.media?.track[0] && bounce.search(json?.media?.track[0].Title) === -1) {
setBounce('Now Playing: ') setBounce('Now Playing: ')
@ -102,10 +106,7 @@ const App = () => {
<div> <div>
<h2>Audio Controls</h2> <h2>Audio Controls</h2>
{audioElmRef.current?.paused ? {audioElmRef.current?.paused ?
<button onClick={useCallback(async () => { <button onClick={() => play()}>Play </button> :
setMuted(false)
await audioElmRef.current?.play()
}, [audioElmRef.current])}>Play </button> :
<button onClick={() => audioElmRef.current?.pause()}>Pause </button> <button onClick={() => audioElmRef.current?.pause()}>Pause </button>
} }
<br /><br /> <br /><br />