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