|
@@ -42,14 +42,16 @@ export default function useMetronome(
|
|
|
let index = 0;
|
|
|
timeTask();
|
|
|
function timeTask() {
|
|
|
- const playVm = index === 0 ? playerTick : playerTock;
|
|
|
+ const bateNum = Number(timeArr[index]);
|
|
|
+ // 当为index=0的时候第一排为重(当为0拍的时候不为重)
|
|
|
+ const playVm = index === 0 && bateNum !== 0 ? playerTick : playerTock;
|
|
|
playVm.play();
|
|
|
- playVm.onended = () => {
|
|
|
- _timeTask = setTimeout(() => {
|
|
|
- index === timeArr.length - 1 ? (index = 0) : index++;
|
|
|
- timeTask();
|
|
|
- }, ((1000 * 60) / speed) * Number(timeArr[index]));
|
|
|
- };
|
|
|
+ _timeTask = setTimeout(() => {
|
|
|
+ playVm.pause();
|
|
|
+ playVm.currentTime = 0;
|
|
|
+ index === timeArr.length - 1 ? (index = 0) : index++;
|
|
|
+ timeTask();
|
|
|
+ }, ((1000 * 60) / speed) * (bateNum || 1)); // 为0拍的时候 变为1
|
|
|
}
|
|
|
}
|
|
|
function computeTimeArr() {
|