Created
May 28, 2020 20:06
-
-
Save emanueleDiVizio/633226f920004c2c829ea126fbf8833e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const useAudioPlayer = (fileName) => { | |
| const playerRef = useRef(null); | |
| useEffect(() => { | |
| playerRef.current = loadPlayer(fileName); | |
| return () => { | |
| playerRef.current.destroy(); | |
| }; | |
| }, []); | |
| const play = (cb) => playerRef.current.play(cb); | |
| const seek = (time, cb) => playerRef.current.seek(time, cb); | |
| const stop = (cb) => playerRef.current.stop(cb); | |
| return [play, seek, stop]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment