|
@@ -26,6 +26,7 @@ import { IPostMessage } from "/src/utils/native-message";
|
|
|
import { usePageVisibility } from "@vant/use";
|
|
|
import { browser } from "/src/utils";
|
|
|
import { getAudioCurrentTime, toggleMutePlayAudio } from "../audio-list";
|
|
|
+import testAudio from './testAudio.mp3'
|
|
|
|
|
|
const browserInfo = browser();
|
|
|
export const evaluatingData = reactive({
|
|
@@ -75,6 +76,7 @@ const check_currentTime = () => {
|
|
|
preTime = state.section[0].time * 1000;
|
|
|
}
|
|
|
const currentTime = getAudioCurrentTime() * 1000 - preTime;
|
|
|
+ console.log('播放进度music', currentTime, 'preTime:' + preTime)
|
|
|
|
|
|
if (currentTime >= 500) {
|
|
|
sendEvaluatingOffsetTime(500);
|
|
@@ -87,13 +89,12 @@ const check_currentTime = () => {
|
|
|
|
|
|
/** 开始播放发送延迟时间 */
|
|
|
export const sendEvaluatingOffsetTime = async (currentTime: number) => {
|
|
|
- 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);
|
|
|
+ console.error("真正播放延迟", delayTime, "currentTime:", currentTime);
|
|
|
await api_proxyServiceMessage({
|
|
|
header: {
|
|
|
commond: "audioPlayStart",
|
|
@@ -206,7 +207,7 @@ export const handleStartBegin = async () => {
|
|
|
evaluatingData.evaluatings = {};
|
|
|
evaluatingData.resultData = {};
|
|
|
evaluatingData.backtime = 0;
|
|
|
- resetPlaybackToStart();
|
|
|
+ // resetPlaybackToStart();
|
|
|
try {
|
|
|
// console.log("🚀 ~ content:", evaluatingData.contentData, JSON.stringify(evaluatingData.contentData));
|
|
|
} catch (error) {}
|
|
@@ -216,17 +217,13 @@ export const handleStartBegin = async () => {
|
|
|
evaluatingData.startBegin = false;
|
|
|
return;
|
|
|
}
|
|
|
- // 开始播放
|
|
|
- // playMusic();
|
|
|
// 开始录音
|
|
|
api_startRecording();
|
|
|
};
|
|
|
|
|
|
/** 播放音乐 */
|
|
|
const playMusic = async () => {
|
|
|
- console.time("真正播放开始的延迟");
|
|
|
const playState = await togglePlay("play");
|
|
|
- console.timeEnd("真正播放开始的延迟");
|
|
|
// 取消播放,停止播放
|
|
|
if (!playState) {
|
|
|
evaluatingData.startBegin = false;
|
|
@@ -242,6 +239,8 @@ const playMusic = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+let _audio: HTMLAudioElement;
|
|
|
+let backtime = 0
|
|
|
/** 录音开始,记录开始时间点 */
|
|
|
const recordStartTimePoint = async (res?: IPostMessage) => {
|
|
|
// 没有开始评测,不处理
|
|
@@ -250,12 +249,45 @@ const recordStartTimePoint = async (res?: IPostMessage) => {
|
|
|
if (browserInfo.ios) {
|
|
|
inteveral *= 1000;
|
|
|
}
|
|
|
- console.log("🚀 ~ 开始时间点:", inteveral, "已经录的时间:", Date.now() - inteveral);
|
|
|
evaluatingData.backtime = inteveral || Date.now();
|
|
|
+ backtime = evaluatingData.backtime
|
|
|
+ console.log("🚀 ~ 开始时间点:", evaluatingData.backtime, "已经录的时间:", Date.now() - inteveral, '记录时间点:', Date.now());
|
|
|
// 开始播放
|
|
|
+ _audio.play();
|
|
|
+
|
|
|
playMusic();
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+const getTestCurrent = () => {
|
|
|
+ const _c = _audio.currentTime * 1000
|
|
|
+ console.log("🚀 ~ 播放的时间:", _c)
|
|
|
+ if (_c > 500){
|
|
|
+ console.log('evaluatingData.backtime: ', evaluatingData.backtime, 'backtime:', backtime)
|
|
|
+ console.error('开始播放的延迟:', Date.now() - backtime - 500)
|
|
|
+ _audio.pause()
|
|
|
+ // playMusic()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ getTestCurrent()
|
|
|
+ }, 10)
|
|
|
+}
|
|
|
+
|
|
|
+const playTestMusic = () => {
|
|
|
+ _audio = new Audio()
|
|
|
+ // _audio.src = testAudio
|
|
|
+ _audio.src = state.accompany
|
|
|
+ _audio.onplay = () => {
|
|
|
+ getTestCurrent()
|
|
|
+ }
|
|
|
+ _audio.onloadedmetadata = () => {
|
|
|
+ console.log('测试音频加载完成')
|
|
|
+ // _audio.play();
|
|
|
+ }
|
|
|
+ _audio.load()
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 结束评测
|
|
|
* @param isComplete 是否完整评测
|
|
@@ -383,6 +415,7 @@ export default defineComponent({
|
|
|
}
|
|
|
});
|
|
|
onMounted(() => {
|
|
|
+ playTestMusic();
|
|
|
hanlde_record();
|
|
|
evaluatingData.resultData = {};
|
|
|
// evaluatingData.resultData = {...getLeveByScore(90), score: 30, intonation: 10, cadence: 30, integrity: 40}
|