|
@@ -17,11 +17,13 @@ import {
|
|
|
api_stopRecording,
|
|
|
api_recordStartTime,
|
|
|
api_remove_recordStartTime,
|
|
|
+ api_videoUpdate,
|
|
|
} from "/src/helpers/communication";
|
|
|
import state, { clearSelection, handleStopPlay, resetPlaybackToStart, togglePlay } from "/src/state";
|
|
|
import { IPostMessage } from "/src/utils/native-message";
|
|
|
import { usePageVisibility } from "@vant/use";
|
|
|
import { browser } from "/src/utils";
|
|
|
+import { toggleMutePlayAudio } from "../audio-list";
|
|
|
|
|
|
const browserInfo = browser();
|
|
|
export const evaluatingData = reactive({
|
|
@@ -65,8 +67,11 @@ export const handleStartEvaluat = () => {
|
|
|
|
|
|
/** 开始播放发送延迟时间 */
|
|
|
export const sendEvaluatingOffsetTime = async (currentTime: number) => {
|
|
|
+ // 没有开始时间点, 没有开始播放, 不处理
|
|
|
+ if (!evaluatingData.backtime || !currentTime) return;
|
|
|
const nowTime = Date.now();
|
|
|
- const delayTime = nowTime - evaluatingData.backtime - currentTime * 1000;
|
|
|
+ const delayTime = nowTime - evaluatingData.backtime
|
|
|
+ evaluatingData.backtime = 0
|
|
|
console.log("真正播放延迟", delayTime);
|
|
|
await api_proxyServiceMessage({
|
|
|
header: {
|
|
@@ -183,7 +188,7 @@ export const handleStartBegin = async () => {
|
|
|
evaluatingData.backtime = 0;
|
|
|
resetPlaybackToStart();
|
|
|
try {
|
|
|
- console.log("🚀 ~ content:", evaluatingData.contentData, JSON.stringify(evaluatingData.contentData));
|
|
|
+ // console.log("🚀 ~ content:", evaluatingData.contentData, JSON.stringify(evaluatingData.contentData));
|
|
|
} catch (error) {}
|
|
|
const res = await startEvaluating(evaluatingData.contentData);
|
|
|
if (res?.api !== "startEvaluating") {
|
|
@@ -191,24 +196,35 @@ export const handleStartBegin = async () => {
|
|
|
evaluatingData.startBegin = false;
|
|
|
return;
|
|
|
}
|
|
|
+ // 开始播放
|
|
|
+ playMusic();
|
|
|
// 开始录音
|
|
|
api_startRecording();
|
|
|
};
|
|
|
|
|
|
-/** 录音开始,开始播放音频 */
|
|
|
-const recordedPlayMusic = async (res?: IPostMessage) => {
|
|
|
- let inteveral = res?.content?.inteveral || 0;
|
|
|
- if (browserInfo.ios) {
|
|
|
- inteveral *= 1000;
|
|
|
- }
|
|
|
- evaluatingData.backtime = inteveral || Date.now();
|
|
|
+/** 播放音乐 */
|
|
|
+const playMusic = async () => {
|
|
|
+ toggleMutePlayAudio()
|
|
|
const playState = await togglePlay("play");
|
|
|
// 取消播放
|
|
|
if (!playState) {
|
|
|
evaluatingData.startBegin = false;
|
|
|
handleCancelEvaluat();
|
|
|
+ toggleMutePlayAudio()
|
|
|
return;
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+/** 录音开始,记录开始时间点 */
|
|
|
+const recordStartTimePoint = async (res?: IPostMessage) => {
|
|
|
+ let inteveral = res?.content?.inteveral || 0;
|
|
|
+ if (browserInfo.ios) {
|
|
|
+ inteveral *= 1000;
|
|
|
+ }
|
|
|
+ console.log("🚀 ~ 开始时间点:", inteveral)
|
|
|
+ evaluatingData.backtime = inteveral || Date.now();
|
|
|
+ toggleMutePlayAudio()
|
|
|
+ resetPlaybackToStart();
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -232,6 +248,8 @@ export const handleEndEvaluat = (isComplete = false) => {
|
|
|
forbidClick: true,
|
|
|
});
|
|
|
evaluatingData.isComplete = isComplete;
|
|
|
+ // 保存视频到相册
|
|
|
+ saveVideoToAlbum();
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -287,6 +305,16 @@ export const handleViewReport = (key: "recordId" | "recordIdStr", type: "gym" |
|
|
|
isOpenLight: true,
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+/** 保存视频到相册 */
|
|
|
+const saveVideoToAlbum = async () => {
|
|
|
+ if (state.setting.saveToAlbum && state.setting.camera){
|
|
|
+ const res = await api_videoUpdate()
|
|
|
+ console.log("保存视频到相册回调:", res)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
export default defineComponent({
|
|
|
name: "evaluating",
|
|
|
setup() {
|
|
@@ -306,14 +334,14 @@ export default defineComponent({
|
|
|
evaluatingData.checkStep = 0;
|
|
|
evaluatingData.rendered = true;
|
|
|
sendResult(handleScoreResult);
|
|
|
- api_recordStartTime(recordedPlayMusic);
|
|
|
+ api_recordStartTime(recordStartTimePoint);
|
|
|
if (!state.isSelectMeasureMode) {
|
|
|
clearSelection();
|
|
|
}
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
removeResult(handleScoreResult);
|
|
|
- api_remove_recordStartTime(recordedPlayMusic);
|
|
|
+ api_remove_recordStartTime(recordStartTimePoint);
|
|
|
});
|
|
|
return () => <div></div>;
|
|
|
},
|