Open nkhanh90 opened 5 years ago
I have setInterval and Sound play same time in useEffect()
const [road, setRoad] = useReducer((state = {top: 0, left: -265, right: 0, bottom: 0, opacity: 1}, action) => { const newState = {...state} if (action.type === 'moving' && action.param) { if (state.left >= action.param) { newState.left -= 10 } else { setStop(true) } } return newState }); const [play, setPlay] = useState('PAUSED') useEffect(() => { setRoad({type: 'moving}) setPlay('PLAYING') }, [])
const [road, setRoad] = useReducer((state = {top: 0, left: -265, right: 0, bottom: 0, opacity: 1}, action) => { const newState = {...state} if (action.type === 'moving' && action.param) { if (state.left >= action.param) { newState.left -= 10 } else { setStop(true) } } return newState });
const [play, setPlay] = useState('PAUSED')
useEffect(() => { setRoad({type: 'moving}) setPlay('PLAYING') }, [])
sound0: waiting soundmanager2.js:1307 sound0: Buffer state change: 1 soundmanager2.js:1307 sound0: setPosition(0) soundmanager2.js:1307 sound0: playing ♫ soundmanager2.js:1307 sound0: Buffer state change: 0 soundmanager2.js:1307 sound0: waiting soundmanager2.js:1307 sound0: Buffer state change: 1 soundmanager2.js:1307 sound0: playing ♫ soundmanager2.js:1307 sound0: Buffer state change: 0 soundmanager2.js:1307 sound0: setPosition(0) soundmanager2.js:1307 sound0: waiting soundmanager2.js:1307 sound0: Buffer state change: 1 soundmanager2.js:1307 sound0: setPosition(0) soundmanager2.js:1307 sound0: playing ♫ soundmanager2.js:1307 sound0: Buffer state change: 0 soundmanager2.js:1307 sound0: waiting soundmanager2.js:1307 sound0: Buffer state change: 1
I have setInterval and Sound play same time in useEffect()
const [road, setRoad] = useReducer((state = {top: 0, left: -265, right: 0, bottom: 0, opacity: 1}, action) => { const newState = {...state} if (action.type === 'moving' && action.param) { if (state.left >= action.param) { newState.left -= 10 } else { setStop(true) } } return newState });
const [play, setPlay] = useState('PAUSED')
useEffect(() => { setRoad({type: 'moving}) setPlay('PLAYING') }, [])