out promises
Signed-off-by: ale <ale@manalejandro.com>
This commit is contained in:
parent
7e8467faae
commit
479c394c50
12
src/App.js
12
src/App.js
@ -32,20 +32,12 @@ const App = () => {
|
|||||||
},
|
},
|
||||||
play = () => {
|
play = () => {
|
||||||
if (audioElmRef.current) {
|
if (audioElmRef.current) {
|
||||||
audioElmRef.current.play().then(() => {
|
audioElmRef.current.play()
|
||||||
setPlayPause(true)
|
|
||||||
}).catch(err => {
|
|
||||||
console.error('Error playing audio: ' + err.message)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pause = () => {
|
pause = () => {
|
||||||
if (audioElmRef.current) {
|
if (audioElmRef.current) {
|
||||||
audioElmRef.current.pause().then(() => {
|
audioElmRef.current.pause()
|
||||||
setPlayPause(false)
|
|
||||||
}).catch(err => {
|
|
||||||
console.error('Error pausing audio: ' + err.message)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadData = () => {
|
loadData = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user