summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/audio/audio.reducer.js
blob: bd6bbae2c69dac3d7f5c97d76c6dddd59fa336e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as types from 'app/types'
// import { session, getDefault, getDefaultInt } from 'app/session'

const initialState = {
  started: false,
  playing: false,
  play_ts: 0,
  seek_ts: 0,
  volume: 1.0,
  cc: true,
}

export default function alignReducer(state = initialState, action) {
  // console.log(action.type, action)
  switch (action.type) {
    case types.audio.play:
      return {
        ...state,
        started: true,
        playing: true,
      }
    case types.audio.pause:
      return {
        ...state,
        playing: false,
      }
    case types.audio.seek:
      return {
        ...state,
        play_ts: action.seek_ts,
        seek_ts: action.seek_ts,
      }
    case types.audio.update_time:
      return {
        ...state,
        play_ts: action.play_ts,
      }
    case types.audio.set_volume:
      return {
        ...state,
        volume: action.volume,
      }
    case types.audio.set_cc:
      return {
        ...state,
        cc: action.value
      }
    default:
      return state
  }
}