|
@@ -69,31 +69,31 @@ export const handleStartEvaluat = () => {
|
|
|
};
|
|
|
|
|
|
const check_currentTime = () => {
|
|
|
- let preTime = 0
|
|
|
+ let preTime = 0;
|
|
|
// 选段评测模式
|
|
|
if (state.isSelectMeasureMode) {
|
|
|
preTime = state.section[0].time * 1000;
|
|
|
}
|
|
|
- const currentTime = getAudioCurrentTime() * 1000 - preTime
|
|
|
-
|
|
|
- if (currentTime >= 500){
|
|
|
- sendEvaluatingOffsetTime(500)
|
|
|
- return
|
|
|
+ const currentTime = getAudioCurrentTime() * 1000 - preTime;
|
|
|
+
|
|
|
+ if (currentTime >= 500) {
|
|
|
+ sendEvaluatingOffsetTime(500);
|
|
|
+ return;
|
|
|
}
|
|
|
setTimeout(() => {
|
|
|
- check_currentTime()
|
|
|
- }, 10)
|
|
|
-}
|
|
|
+ check_currentTime();
|
|
|
+ }, 10);
|
|
|
+};
|
|
|
|
|
|
/** 开始播放发送延迟时间 */
|
|
|
export const sendEvaluatingOffsetTime = async (currentTime: number) => {
|
|
|
- console.log("🚀 ~ currentTime:", currentTime)
|
|
|
+ console.log("🚀 ~ currentTime:", currentTime);
|
|
|
// 没有开始时间点, 不处理
|
|
|
if (!evaluatingData.backtime) return;
|
|
|
const nowTime = Date.now();
|
|
|
- const delayTime = nowTime - evaluatingData.backtime - currentTime
|
|
|
- evaluatingData.backtime = 0
|
|
|
- console.log("真正播放延迟", delayTime, 'currentTime:', currentTime);
|
|
|
+ const delayTime = nowTime - evaluatingData.backtime - currentTime;
|
|
|
+ evaluatingData.backtime = 0;
|
|
|
+ console.log("真正播放延迟", delayTime, "currentTime:", currentTime);
|
|
|
await api_proxyServiceMessage({
|
|
|
header: {
|
|
|
commond: "audioPlayStart",
|
|
@@ -224,9 +224,9 @@ export const handleStartBegin = async () => {
|
|
|
|
|
|
/** 播放音乐 */
|
|
|
const playMusic = async () => {
|
|
|
- console.time('真正播放开始的延迟')
|
|
|
+ console.time("真正播放开始的延迟");
|
|
|
const playState = await togglePlay("play");
|
|
|
- console.timeEnd('真正播放开始的延迟')
|
|
|
+ console.timeEnd("真正播放开始的延迟");
|
|
|
// 取消播放,停止播放
|
|
|
if (!playState) {
|
|
|
evaluatingData.startBegin = false;
|
|
@@ -234,23 +234,23 @@ const playMusic = async () => {
|
|
|
return;
|
|
|
}
|
|
|
// 检测播放进度, 计算延迟
|
|
|
- check_currentTime()
|
|
|
+ check_currentTime();
|
|
|
// 如果开启了摄像头, 开启录制视频
|
|
|
- if (state.setting.camera && state.setting.saveToAlbum){
|
|
|
- console.log('开始录制视频')
|
|
|
- api_startCapture()
|
|
|
+ if (state.setting.camera && state.setting.saveToAlbum) {
|
|
|
+ console.log("开始录制视频");
|
|
|
+ api_startCapture();
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
/** 录音开始,记录开始时间点 */
|
|
|
const recordStartTimePoint = async (res?: IPostMessage) => {
|
|
|
// 没有开始评测,不处理
|
|
|
- if (!evaluatingData.startBegin) return
|
|
|
+ if (!evaluatingData.startBegin) return;
|
|
|
let inteveral = res?.content?.inteveral || 0;
|
|
|
if (browserInfo.ios) {
|
|
|
inteveral *= 1000;
|
|
|
}
|
|
|
- console.log("🚀 ~ 开始时间点:", inteveral, '已经录的时间:', Date.now() - inteveral)
|
|
|
+ console.log("🚀 ~ 开始时间点:", inteveral, "已经录的时间:", Date.now() - inteveral);
|
|
|
evaluatingData.backtime = inteveral || Date.now();
|
|
|
// 开始播放
|
|
|
playMusic();
|
|
@@ -278,9 +278,9 @@ export const handleEndEvaluat = (isComplete = false) => {
|
|
|
});
|
|
|
evaluatingData.isComplete = isComplete;
|
|
|
// 如果开启了摄像头, 结束录制视频
|
|
|
- if (state.setting.camera && state.setting.saveToAlbum){
|
|
|
- console.log('结束录制视频')
|
|
|
- api_endCapture()
|
|
|
+ if (state.setting.camera && state.setting.saveToAlbum) {
|
|
|
+ console.log("结束录制视频");
|
|
|
+ api_endCapture();
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -338,14 +338,31 @@ export const handleViewReport = (key: "recordId" | "recordIdStr", type: "gym" |
|
|
|
});
|
|
|
setTimeout(() => {
|
|
|
evaluatingData.resulstMode = false;
|
|
|
- }, 1000)
|
|
|
+ }, 1000);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
export default defineComponent({
|
|
|
name: "evaluating",
|
|
|
setup() {
|
|
|
const pageVisibility = usePageVisibility();
|
|
|
+ // 需要记录的数据
|
|
|
+ const record_old_data = reactive({
|
|
|
+ /** 指法 */
|
|
|
+ finger: false,
|
|
|
+ });
|
|
|
+ /** 记录状态 */
|
|
|
+ const hanlde_record = () => {
|
|
|
+ // 取消指法
|
|
|
+ record_old_data.finger = state.setting.displayFingering;
|
|
|
+ state.setting.displayFingering = false;
|
|
|
+ // 切换为伴奏
|
|
|
+ // if (state.)
|
|
|
+ };
|
|
|
+ /** 还原状态 */
|
|
|
+ const handle_reduction = () => {
|
|
|
+ // 还原指法
|
|
|
+ state.setting.displayFingering = record_old_data.finger;
|
|
|
+ };
|
|
|
|
|
|
watch(pageVisibility, (value) => {
|
|
|
if (value == "hidden" && evaluatingData.startBegin) {
|
|
@@ -353,6 +370,7 @@ export default defineComponent({
|
|
|
}
|
|
|
});
|
|
|
onMounted(() => {
|
|
|
+ hanlde_record();
|
|
|
evaluatingData.resultData = {};
|
|
|
// evaluatingData.resultData = {...getLeveByScore(90), score: 30, intonation: 10, cadence: 30, integrity: 40}
|
|
|
// console.log("🚀 ~ evaluatingData.resultData:", evaluatingData.resultData)
|
|
@@ -362,15 +380,17 @@ export default defineComponent({
|
|
|
evaluatingData.rendered = true;
|
|
|
sendResult(handleScoreResult);
|
|
|
api_recordStartTime(recordStartTimePoint);
|
|
|
+ // 不是选段模式评测, 就清空已选段
|
|
|
if (!state.isSelectMeasureMode) {
|
|
|
clearSelection();
|
|
|
}
|
|
|
- console.log('加载评测模块成功')
|
|
|
+ console.log("加载评测模块成功");
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
removeResult(handleScoreResult);
|
|
|
api_remove_recordStartTime(recordStartTimePoint);
|
|
|
- console.log('卸载评测模块成功')
|
|
|
+ handle_reduction();
|
|
|
+ console.log("卸载评测模块成功");
|
|
|
});
|
|
|
return () => <div></div>;
|
|
|
},
|