|
@@ -8,7 +8,7 @@ import store from "store";
|
|
|
import { formateTimes } from "../../helpers/formateMusic";
|
|
|
import { setCustomGradual, setCustomNoteRealValue } from "/src/helpers/customMusicScore"
|
|
|
import { initSmoothAnimation, smoothAnimationState, destroySmoothAnimation, moveSmoothAnimationByPlayTime } from "../view-detail/smoothAnimation";
|
|
|
-import { api_cloudLoading, simple_musicPage, simple_play, api_suspendPlay } from "/src/helpers/communication";
|
|
|
+import { api_cloudLoading, simple_musicPage } from "/src/helpers/communication";
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: "simple-detail",
|
|
@@ -22,40 +22,40 @@ export default defineComponent({
|
|
|
});
|
|
|
|
|
|
const communicateCb = (res: any) => {
|
|
|
+ let resInfo: any = {};
|
|
|
try {
|
|
|
- const data = JSON.parse(res.data);
|
|
|
- console.log('Received data:', data);
|
|
|
+ resInfo = typeof res?.data === 'string' ? JSON.parse(res.data) : res.data;
|
|
|
+ // console.log('Received data:', resInfo);
|
|
|
} catch (error) {
|
|
|
console.error('parse_error: Invalid JSON data received');
|
|
|
}
|
|
|
- console.log('h5消息',res)
|
|
|
// 开始播放
|
|
|
- if (res?.data?.api === "api_play") {
|
|
|
+ if (resInfo?.api === "api_play") {
|
|
|
console.log('h5开始播放')
|
|
|
state.playState = 'play';
|
|
|
setStep();
|
|
|
}
|
|
|
// 暂停播放
|
|
|
- if (res?.data?.api === "api_paused") {
|
|
|
+ if (resInfo?.api === "api_paused") {
|
|
|
console.log('暂停播放')
|
|
|
state.playState = 'paused';
|
|
|
}
|
|
|
// 暂停状态下,拖动进度
|
|
|
- if (res?.data?.api === "api_updateProgress") {
|
|
|
+ if (resInfo?.api === "api_updateProgress") {
|
|
|
console.log('拖动的进度')
|
|
|
if (state.playState === 'paused') {
|
|
|
- detailData.currentTime = res?.data?.content?.currentTime ? res?.data?.content?.currentTime : detailData.currentTime;
|
|
|
+ detailData.currentTime = resInfo?.content?.currentTime ? resInfo?.content?.currentTime : detailData.currentTime;
|
|
|
handlePlaying();
|
|
|
}
|
|
|
}
|
|
|
// 播放进度
|
|
|
- if (res?.data?.api === "api_playProgress") {
|
|
|
- console.log('播放进度',res)
|
|
|
- if (res?.data?.content?.currentTime) {
|
|
|
- if (res?.data?.content?.currentTime < detailData.currentTime) {
|
|
|
+ if (resInfo?.api === "api_playProgress") {
|
|
|
+ // console.log('播放进度',resInfo)
|
|
|
+ if (resInfo?.content?.currentTime) {
|
|
|
+ if (resInfo?.content?.currentTime < detailData.currentTime) {
|
|
|
state.activeNoteIndex = 0
|
|
|
}
|
|
|
- detailData.currentTime = res?.data?.content?.currentTime
|
|
|
+ detailData.currentTime = resInfo?.content?.currentTime
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -72,14 +72,6 @@ export default defineComponent({
|
|
|
|
|
|
};
|
|
|
|
|
|
- const simplePlay = (e: any) => {
|
|
|
- console.log('app开始播放','消息对象',e)
|
|
|
- state.playState = 'play';
|
|
|
- setStep();
|
|
|
- }
|
|
|
- const suspendPlay = (e: any) => {
|
|
|
- console.log('app切到后台','消息对象',e)
|
|
|
- }
|
|
|
onMounted(async () => {
|
|
|
const id = query.id || '';
|
|
|
state.isSimplePage = true;
|
|
@@ -87,8 +79,6 @@ export default defineComponent({
|
|
|
detailData.isLoading = false;
|
|
|
state.isSingleLine = true;
|
|
|
window.addEventListener("message", communicateCb);
|
|
|
- simple_play(simplePlay);
|
|
|
- api_suspendPlay(suspendPlay);
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|