Ver Fonte

优化选段结束

liushengqiang há 2 anos atrás
pai
commit
407aa5cd49
1 ficheiros alterados com 6 adições e 3 exclusões
  1. 6 3
      src/state.ts

+ 6 - 3
src/state.ts

@@ -8,7 +8,7 @@ import { IFingering } from "src/view/fingering/fingering-config";
 import { handleStartTick } from "./view/tick";
 import { audioListStart, getAudioCurrentTime, getAudioDuration, setAudioCurrentTime, setAudioPlaybackRate } from "./view/audio-list";
 import { toggleFollow } from "./view/follow-practice";
-import { setStorageSpeed } from "./utils";
+import { browser, setStorageSpeed } from "./utils";
 
 /** 入门 | 进阶 | 大师 */
 export type IDifficulty = "BEGINNER" | "ADVANCED" | "PERFORMER";
@@ -154,6 +154,8 @@ const state = reactive({
 	/** 是否是评分显示 */
 	isReport: false
 });
+const browserInfo = browser()
+let offset_duration = 0
 /** 自定义数据 */
 export const customData = reactive({
 	/** 自定义音符时值 */
@@ -191,6 +193,7 @@ const setStep = () => {
 export const onPlay = () => {
 	console.log("开始播放");
 	state.playEnd = false;
+	offset_duration = browserInfo.xiaomi ? 0.2 : 0.08
 	setStep();
 };
 /** 播放中事件 */
@@ -239,8 +242,8 @@ const handlePlaying = () => {
 			// 如果开启了预备拍
 			const selectStartItem = state.sectionFirst ? state.sectionFirst : state.section[0];
 			const selectEndItem = state.section[1];
-
-			if (item.MeasureNumberXML < selectStartItem.MeasureNumberXML || item.MeasureNumberXML > selectEndItem.MeasureNumberXML) {
+				
+			if (Math.abs(selectEndItem.endtime - currentTime) < offset_duration) {
 				console.log("选段播放结束");
 				// 如果为选段评测模式
 				if (state.modeType === "evaluating" && state.isSelectMeasureMode) {