|
@@ -144,6 +144,8 @@ const state = reactive({
|
|
|
basePlayRate: 1,
|
|
|
/** 播放中,更加当前小节速度动态计算的展示速度 */
|
|
|
playIngSpeed: 90,
|
|
|
+ /** 上一次app返回的播放进度 */
|
|
|
+ preAppAudioPlayTime: 0,
|
|
|
})
|
|
|
|
|
|
const syncStepIndex = (i: number) => {
|
|
@@ -655,8 +657,6 @@ let nowTime = 0
|
|
|
|
|
|
let prevTime: number = 0
|
|
|
|
|
|
-let preAppAudioPlayTime = 0; // 上一次app返回的播放进度
|
|
|
-
|
|
|
// 播放中一直触发
|
|
|
const accelerateRefreshPlayer = () => {
|
|
|
if (timer || !state.audiosInstance) {
|
|
@@ -1047,30 +1047,33 @@ export const setAudioInit = () => {
|
|
|
})
|
|
|
// 监听评测曲谱音频播放进度,返回
|
|
|
listenerMessage("playProgress", (res) => {
|
|
|
- const time = res?.content.currentTime / 1000
|
|
|
- const diffTime = res?.content?.currentTime - preAppAudioPlayTime;
|
|
|
- preAppAudioPlayTime = res?.content?.currentTime
|
|
|
- // console.log('app返回的mp3进度',time)
|
|
|
- if (diffTime < 0) {
|
|
|
- console.log('进度返回异常','本次时间比上次慢',diffTime,'当前播放时间:',res?.content?.currentTime)
|
|
|
- return
|
|
|
- }
|
|
|
- requestAnimationFrame(async () => {
|
|
|
- if (state.playState === 'play') {
|
|
|
- state.currentTimeNum = time
|
|
|
- refreshPlayer(time)
|
|
|
- // console.log(66666663333)
|
|
|
- refreshIndex(time)
|
|
|
- // 播放到最后一秒,停止播放
|
|
|
- if (res?.content?.totalDuration > 1000 && res?.content?.currentTime >= res?.content?.totalDuration) {
|
|
|
- console.log('播放结束123')
|
|
|
- state.playState = 'pause'
|
|
|
- state.playEndCallback.endEvaluat()
|
|
|
- ended(new Event('ended'))
|
|
|
- }
|
|
|
+ if (state.playState === 'play') {
|
|
|
+ const time = res?.content.currentTime / 1000
|
|
|
+ const diffTime = res?.content?.currentTime - state.preAppAudioPlayTime;
|
|
|
+
|
|
|
+ // console.log('app返回的mp3进度',time)
|
|
|
+ if (diffTime < 0) {
|
|
|
+ console.log('进度返回异常','本次时间比上次慢',diffTime,'当前播放时间:',res?.content?.currentTime)
|
|
|
+ return
|
|
|
}
|
|
|
- refreshView()
|
|
|
- })
|
|
|
+ state.preAppAudioPlayTime = res?.content?.currentTime
|
|
|
+ requestAnimationFrame(async () => {
|
|
|
+ if (state.playState === 'play') {
|
|
|
+ state.currentTimeNum = time
|
|
|
+ refreshPlayer(time)
|
|
|
+ // console.log(66666663333)
|
|
|
+ refreshIndex(time)
|
|
|
+ // 播放到最后一秒,停止播放
|
|
|
+ if (res?.content?.totalDuration > 1000 && res?.content?.currentTime >= res?.content?.totalDuration) {
|
|
|
+ console.log('播放结束123')
|
|
|
+ state.playState = 'pause'
|
|
|
+ state.playEndCallback.endEvaluat()
|
|
|
+ ended(new Event('ended'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ refreshView()
|
|
|
+ })
|
|
|
+ }
|
|
|
});
|
|
|
state.audiosInstance.event.on('timeupdate', () => {
|
|
|
state.currentTimeNum = state.audiosInstance.currentTime
|