summaryrefslogtreecommitdiff
path: root/frontend/site/audio/audio.reducer.js
blob: 9cdda548c69c7fa873e44e9314fee18ea89beb74 (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
import AudioPlayer from 'site/audio/audio.player'
import * as types from 'site/types'

const initialState = {
  player: new AudioPlayer(),
  muted: false,
}

export default function audioReducer(state = initialState, action) {
  // console.log(action.type, action)
  switch (action.type) {
    case types.site.loaded:
      state.player.load(action.data.graph)
      return state

    case types.site.mute_audio:
      state.player.toggleMuted(true)
      return {
        ...state,
        muted: true,
      }

    case types.site.unmute_audio:
      state.player.toggleMuted(false)
      return {
        ...state,
        muted: false,
      }

    default:
      return state
  }
}