|
@ -25,13 +25,7 @@ function isLeftFinished(state: MeasureState) { |
|
|
return true; |
|
|
return true; |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
const audioList: HTMLAudioElement[] = [] |
|
|
|
|
|
function pauseAudio(){ |
|
|
|
|
|
audioList.forEach(audio => { |
|
|
|
|
|
audio.pause() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let status: 1| 2 ; |
|
|
export const measureSlice = createSlice({ |
|
|
export const measureSlice = createSlice({ |
|
|
name: 'measure', |
|
|
name: 'measure', |
|
|
initialState, |
|
|
initialState, |
|
@ -48,27 +42,15 @@ export const measureSlice = createSlice({ |
|
|
state.leftPoints = []; |
|
|
state.leftPoints = []; |
|
|
state.rightPoints = []; |
|
|
state.rightPoints = []; |
|
|
} |
|
|
} |
|
|
if(action.payload === 'WAITING_FOR_RECORD_THE_2ND_SIDE'){ |
|
|
|
|
|
const audio3 = new Audio('/audio/ticking.wav'); |
|
|
|
|
|
audio3.play().then(() => {}); |
|
|
|
|
|
audioList.push(audio3) |
|
|
|
|
|
} else { |
|
|
|
|
|
if (action.payload === 'START_RECORD_LEFT') { |
|
|
|
|
|
const audio1 = new Audio('/audio/ticking.wav'); |
|
|
|
|
|
audio1.play().then(() => {}); |
|
|
|
|
|
audioList.push(audio1) |
|
|
|
|
|
} else if (action.payload === 'START_RECORD_RIGHT') { |
|
|
|
|
|
// const audio3 = new Audio('/audio/ticking.wav');
|
|
|
|
|
|
// audio3.play().then(() => {});
|
|
|
|
|
|
// audioList.push(audio3)
|
|
|
|
|
|
} else if (action.payload === 'FINISH_RECORD') { |
|
|
|
|
|
const audio4 = new Audio('/audio/ticking.wav'); |
|
|
|
|
|
audio4.play().then(() => {}); |
|
|
|
|
|
audioList.push(audio4) |
|
|
|
|
|
} else if (action.payload === 'WRONG_SIDE') { |
|
|
|
|
|
const audio5 = new Audio('/audio/ticking.wav'); |
|
|
|
|
|
audio5.play().then(() => {}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(action.payload === 'WAITING_FOR_RECORD_THE_1ST_SIDE') { |
|
|
|
|
|
status = 1 |
|
|
|
|
|
}else if(action.payload === 'WAITING_FOR_RECORD_THE_2ND_SIDE') { |
|
|
|
|
|
status = 2 |
|
|
|
|
|
} |
|
|
|
|
|
if((['START_RECORD_LEFT', 'START_RECORD_RIGHT'].includes(action.payload) && status === 1) || (['FINISH_RECORD_LEFT', 'FINISH_RECORD_RIGHT'].includes(action.payload) && status === 1) || ['FINISH_RECORD'].includes(action.payload)) { |
|
|
|
|
|
const audio = new Audio('/audio/ticking.wav'); |
|
|
|
|
|
audio.play().then(() => {}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
addNewPoint: (state, action: PayloadAction<TrackRecordSig['data']>) => { |
|
|
addNewPoint: (state, action: PayloadAction<TrackRecordSig['data']>) => { |
|
|