Sfoglia il codice sorgente

修改延迟计算方式

liushengqiang 2 anni fa
parent
commit
8847ed4bfe

+ 4 - 0
src/page-orchestra/api.ts

@@ -30,3 +30,7 @@ export const studentLessonTrainingLessonTrainingRecord = (data: any) => {
 export const studentMember = () => {
 	return request.get("/student/member");
 };
+/** 获取学习会员信息 */
+export const sysSuggestionSave = (data: any) => {
+	return request.post("/sysSuggestion/save",  { data });
+};

+ 2 - 2
src/page-orchestra/custom-plugins/helper-model/recommendation/index.tsx

@@ -1,8 +1,8 @@
 import { defineComponent, reactive, ref } from "vue";
 import styles from "./index.module.less";
 import { Cell, Field, Tab, Tabs, showToast } from "vant";
-import { sysSuggestionAdd } from "/src/page-colexiu/api";
 import iconSubmit from "../icons/icon-submit.png";
+import { sysSuggestionSave } from "/src/page-orchestra/api";
 
 export default defineComponent({
 	name: "recommendation",
@@ -26,7 +26,7 @@ export default defineComponent({
 			}
 			recommenData.loading = true;
 			try {
-				await sysSuggestionAdd({
+				await sysSuggestionSave({
 					content: recommenData.message + "#" + recommenData.active,
 					type: "SMART_PRACTICE",
 				});

+ 1 - 1
src/page-orchestra/evaluat-model/index.module.less

@@ -22,7 +22,7 @@
   .endBtn{
     position: fixed;
     left: 50%;
-    top: 16px;
+    bottom: 10px;
     width: 120px;
     height: 40px;
     margin-left: -70px;

+ 1 - 9
src/state.ts

@@ -3,7 +3,7 @@ import { reactive } from "vue";
 import { OpenSheetMusicDisplay } from "../osmd-extended/src";
 import { metronomeData } from "./helpers/metronome";
 import { GradualNote, GradualTimes, GradualVersion } from "./type";
-import { handleEndEvaluat, handleStartEvaluat, sendEvaluatingOffsetTime } from "./view/evaluating";
+import { handleEndEvaluat, handleStartEvaluat } from "./view/evaluating";
 import { IFingering } from "src/view/fingering/fingering-config";
 import { handleStartTick } from "./view/tick";
 import { audioListStart, getAudioCurrentTime, getAudioDuration, setAudioCurrentTime, setAudioPlaybackRate } from "./view/audio-list";
@@ -192,14 +192,6 @@ export const onPlay = () => {
 	console.log("开始播放");
 	state.playEnd = false;
 	setStep();
-	if (state.modeType === "evaluating") {
-		let currentTime = getAudioCurrentTime();
-		// 选段评测模式
-		if (state.isSelectMeasureMode) {
-			currentTime = currentTime - state.section[0].time;
-		}
-		sendEvaluatingOffsetTime(getAudioCurrentTime())
-	}
 };
 /** 播放中事件 */
 export const onTimeupdate = (evt: Event) => {

+ 23 - 4
src/view/evaluating/index.tsx

@@ -25,7 +25,7 @@ import state, { clearSelection, handleStopPlay, resetPlaybackToStart, togglePlay
 import { IPostMessage } from "/src/utils/native-message";
 import { usePageVisibility } from "@vant/use";
 import { browser } from "/src/utils";
-import { toggleMutePlayAudio } from "../audio-list";
+import { getAudioCurrentTime, toggleMutePlayAudio } from "../audio-list";
 
 const browserInfo = browser();
 export const evaluatingData = reactive({
@@ -67,15 +67,32 @@ export const handleStartEvaluat = () => {
 	}
 };
 
+const check_currentTime = () => {
+	let preTime = 0
+	// 选段评测模式
+	if (state.isSelectMeasureMode) {
+		preTime = state.section[0].time * 1000;
+	}
+	const currentTime = getAudioCurrentTime() * 1000 - preTime
+	
+	if (currentTime >= 500){
+		sendEvaluatingOffsetTime(500)
+		return
+	}
+	setTimeout(() => {
+		check_currentTime()
+	}, 10)
+}
+
 /** 开始播放发送延迟时间 */
 export const sendEvaluatingOffsetTime = async (currentTime: number) => {
 	console.log("🚀 ~ currentTime:", currentTime)
 	// 没有开始时间点, 不处理
 	if (!evaluatingData.backtime) return;
 	const nowTime = Date.now();
-	const delayTime = nowTime - evaluatingData.backtime
+	const delayTime = nowTime - evaluatingData.backtime - currentTime
 	evaluatingData.backtime = 0
-	console.log("真正播放延迟", delayTime);
+	console.log("真正播放延迟", delayTime, 'currentTime:', currentTime);
 	await api_proxyServiceMessage({
 		header: {
 			commond: "audioPlayStart",
@@ -217,6 +234,8 @@ const playMusic = async () => {
 		// toggleMutePlayAudio(state.playSource, false)
 		return;
 	}
+	// 检测播放进度, 计算延迟
+	check_currentTime()
 	// 如果开启了摄像头, 开启录制视频
 	if (state.setting.camera && state.setting.saveToAlbum){
 		console.log('开始录制视频')
@@ -232,7 +251,7 @@ const recordStartTimePoint = async (res?: IPostMessage) => {
 	if (browserInfo.ios) {
 		inteveral *= 1000;
 	}
-	console.log("🚀 ~ 开始时间点:", inteveral)
+	console.log("🚀 ~ 开始时间点:", inteveral, '已经录的时间:', Date.now() - inteveral)
 	evaluatingData.backtime = inteveral || Date.now();
 	// toggleMutePlayAudio(state.playSource, false)
 	// resetPlaybackToStart();