|
@@ -22,11 +22,24 @@ 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 === "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
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -42,10 +55,10 @@ export default defineComponent({
|
|
|
|
|
|
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);
|
|
|
window.addEventListener("message", communicateCb);
|
|
|
});
|
|
@@ -92,15 +105,13 @@ export default defineComponent({
|
|
|
* 播放一直触发的事件
|
|
|
*/
|
|
|
const handlePlaying = () => {
|
|
|
- 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
|
|
|
// 一行谱,需要滚动小节
|
|
|
if (state.isSingleLine) {
|
|
|
moveSmoothAnimationByPlayTime(currentTime)
|