|
@@ -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_playProgress } from "/src/helpers/communication";
|
|
|
+import { api_playProgress, api_cloudLoading, simple_playProgress, simple_remove_playProgress, simple_play, simple_paused, simple_updateProgress } from "/src/helpers/communication";
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: "simple-detail",
|
|
@@ -22,31 +22,60 @@ export default defineComponent({
|
|
|
});
|
|
|
|
|
|
const communicateCb = (res: any) => {
|
|
|
+ // console.log('h5消息',res)
|
|
|
+ // 开始播放
|
|
|
+ if (res?.data?.api === "api_play") {
|
|
|
+ console.log('开始播放')
|
|
|
+ state.playState = 'play';
|
|
|
+ setStep();
|
|
|
+ }
|
|
|
+ // 暂停播放
|
|
|
+ if (res?.data?.api === "api_paused") {
|
|
|
+ console.log('暂停播放')
|
|
|
+ state.playState = 'paused';
|
|
|
+ }
|
|
|
+ // 暂停状态下,拖动进度
|
|
|
+ if (res?.data?.api === "api_updateProgress") {
|
|
|
+ console.log('拖动的进度')
|
|
|
+ if (state.playState === 'paused') {
|
|
|
+ detailData.currentTime = res?.data?.data ? res?.data?.data : detailData.currentTime;
|
|
|
+ handlePlaying();
|
|
|
+ }
|
|
|
+ }
|
|
|
// 播放进度
|
|
|
- if (res?.data?.api === "playProgress") {
|
|
|
+ if (res?.data?.api === "api_playProgress") {
|
|
|
if (res?.data.data) {
|
|
|
- state.playState = 'play';
|
|
|
- console.log(res.data)
|
|
|
+ if (res?.data.data < detailData.currentTime) {
|
|
|
+ state.activeNoteIndex = 0
|
|
|
+ }
|
|
|
+ detailData.currentTime = res?.data.data
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
// 监听评测曲谱音频播放进度,返回
|
|
|
const progress = (res: any) => {
|
|
|
- detailData.currentTime = res?.currentTime || res?.content?.currentTime;
|
|
|
- detailData.totalTime = res?.totalDuration || res?.content?.totalDuration;
|
|
|
- const time = detailData.currentTime / 1000;
|
|
|
- if (res?.content?.totalDuration > 1000 && detailData.currentTime >= detailData.totalTime) {
|
|
|
- // 播放结束
|
|
|
+ const currentTime = res?.currentTime || res?.content?.currentTime;
|
|
|
+ if (currentTime) {
|
|
|
+ if (currentTime < detailData.currentTime) {
|
|
|
+ state.activeNoteIndex = 0
|
|
|
+ }
|
|
|
+ detailData.currentTime = currentTime
|
|
|
}
|
|
|
+
|
|
|
};
|
|
|
|
|
|
+ const simplePlay = () => {
|
|
|
+ state.playState = 'play';
|
|
|
+ setStep();
|
|
|
+ }
|
|
|
onMounted(async () => {
|
|
|
const id = query.id || '';
|
|
|
- await getMusicDetail(id);
|
|
|
+ state.isSimplePage = true;
|
|
|
+ await getMusicDetail(id, 'open');
|
|
|
detailData.isLoading = false;
|
|
|
state.isSingleLine = true;
|
|
|
- state.isSimplePage = true;
|
|
|
- api_playProgress(progress);
|
|
|
+ simple_playProgress(progress);
|
|
|
+ simple_play(simplePlay);
|
|
|
window.addEventListener("message", communicateCb);
|
|
|
});
|
|
|
|
|
@@ -56,7 +85,7 @@ export default defineComponent({
|
|
|
});
|
|
|
/** 渲染完成 */
|
|
|
const handleRendered = async (osmd: any) => {
|
|
|
- console.log('渲染完成')
|
|
|
+ const svgHeight = document.getElementById('scrollContainer')?.getBoundingClientRect().height;
|
|
|
state.osmd = osmd;
|
|
|
// 没有设置速度使用读取的速度
|
|
|
if (state.originSpeed === 0) {
|
|
@@ -76,23 +105,31 @@ export default defineComponent({
|
|
|
// 一行谱创建 动画
|
|
|
initSmoothAnimation();
|
|
|
//destroySmoothAnimation();
|
|
|
- smoothAnimationState.isShow.value = false;
|
|
|
- state.playState = 'play';
|
|
|
- setStep();
|
|
|
+ //smoothAnimationState.isShow.value = false;
|
|
|
+ api_cloudLoading();
|
|
|
+ console.log('渲染完成',svgHeight)
|
|
|
+ window.parent.postMessage(
|
|
|
+ {
|
|
|
+ api: "api_musicPage",
|
|
|
+ height: svgHeight
|
|
|
+ },
|
|
|
+ "*"
|
|
|
+ );
|
|
|
+ // state.playState = 'play';
|
|
|
+ // setStep();
|
|
|
};
|
|
|
/**
|
|
|
* 播放一直触发的事件
|
|
|
*/
|
|
|
const handlePlaying = () => {
|
|
|
- detailData.currentTime += 0.03;
|
|
|
+ //detailData.currentTime += 0.03
|
|
|
const currentTime = detailData.currentTime;
|
|
|
- const duration = detailData.totalTime;
|
|
|
- state.playProgress = (currentTime / duration) * 100;
|
|
|
// console.log('👀~播放进度',currentTime)
|
|
|
let item = getNote(currentTime);
|
|
|
if (item) {
|
|
|
gotoNext(item);
|
|
|
}
|
|
|
+ state.activeNoteIndex = item?.i || 0
|
|
|
// 一行谱,需要滚动小节
|
|
|
if (state.isSingleLine) {
|
|
|
moveSmoothAnimationByPlayTime(currentTime)
|