audio load
Signed-off-by: ale <ale@manalejandro.com>
This commit is contained in:
parent
0ff53b190d
commit
51b6250760
11
src/App.js
11
src/App.js
@ -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 />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user