1234567891011121314151617181920212223242526272829303132 |
- export function playerReducer(state={},{
- type,
- isPlaying=false,
- isStopped,
- duration,
- track,
- // playlist: {_id, name, tracks},
- playlistIndex,
- currentTime=0,
- volume,
- }) {
- if (type === 'TRACK_PLAY') {
- return {
- ...state,
- isPlaying,
- isStopped: !isPlaying,
- };
- }
- if (type === 'TRACK_STOP') {
- return {
- ...state,
- isStopped,
- isPlaying: !isStopped,
- };
- }
- return state
- }
- export const actionTrackPlay = (track,isPlaying) => ({type: "TRACK_PLAY",isPlaying: track.play()})
- export const actionTrackStop = (track,isStopped) => ({type: "TRACK_PLAY",isStopped: track.pause()})
|