Browse Source

feat: 音频比选段的xml时值短兼容

TIANYONG 2 weeks ago
parent
commit
27ae2051ac
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/state.ts

+ 7 - 1
src/state.ts

@@ -529,7 +529,13 @@ const handlePlaying = () => {
       const selectStartItem = state.sectionFirst ? state.sectionFirst : state.section[0];
       const selectEndItem = state.section[1];
       // 如果选段播放结束,或者音频播放结束(判断条件:currentTime >= duration)
-      if ( (currentTime - selectEndItem.endtime >= 0) || (currentTime >= duration) ) {
+      // console.log('时间',currentTime,duration)
+      /**
+       * TODO:兼容音频时长比xml时值短的曲子
+       * isAudioShort:音频比选段的xml时值短,部分手机最后一帧返回的currentTime会比duration小,在这里加上一帧的时间(0.1666~0.2)
+       */
+      const isAudioShort = duration < selectEndItem.endtime
+      if ( (currentTime - selectEndItem.endtime >= 0) || (isAudioShort && (currentTime+0.02 >= duration)) ) {
         console.log("选段播放结束", state.setting.repeatAutoPlay);
         // 如果为选段评测模式
         if (state.modeType === "evaluating" && state.isSelectMeasureMode) {