@@ -627,7 +627,9 @@ export abstract class LyricPlayerBase
627627 . reduce (
628628 ( acc , el ) =>
629629 acc +
630- ( el . getLine ( ) . isBG ? 0 : ( this . lyricLinesSize . get ( el ) ?. [ 1 ] ?? 0 ) ) ,
630+ ( el . getLine ( ) . isBG && this . isPlaying
631+ ? 0
632+ : ( this . lyricLinesSize . get ( el ) ?. [ 1 ] ?? 0 ) ) ,
631633 0 ,
632634 ) ;
633635 this . scrollBoundary [ 0 ] = - scrollOffset ;
@@ -673,8 +675,12 @@ export abstract class LyricPlayerBase
673675 let targetOpacity : number ;
674676
675677 if ( this . hidePassedLines ) {
676- if ( i < ( interlude ? interlude [ 2 ] + 1 : this . scrollToIndex ) ) {
677- targetOpacity = 0 ;
678+ if (
679+ i < ( interlude ? interlude [ 2 ] + 1 : this . scrollToIndex ) &&
680+ this . isPlaying
681+ ) {
682+ // 为了避免浏览器优化,这里使用了一个极小但不为零的值(几乎不可见)
683+ targetOpacity = 0.00001 ;
678684 } else if ( hasBuffered ) {
679685 targetOpacity = 0.85 ;
680686 } else {
@@ -706,30 +712,33 @@ export abstract class LyricPlayerBase
706712
707713 const SCALE_ASPECT = this . enableScale ? 97 : 100 ;
708714
715+ let targetScale = 100 ;
716+
717+ if ( ! isActive && this . isPlaying ) {
718+ if ( line . isBG ) {
719+ targetScale = 75 ;
720+ } else {
721+ targetScale = SCALE_ASPECT ;
722+ }
723+ }
724+
709725 lineObj . setTransform (
710726 curPos ,
711- isActive ? 100 : line . isBG ? 75 : SCALE_ASPECT ,
727+ targetScale ,
712728 targetOpacity ,
713729 window . innerWidth <= 1024 ? blurLevel * 0.8 : blurLevel ,
714730 force ,
715731 delay ,
716732 ) ;
717- if ( line . isBG && isActive ) {
733+ if ( line . isBG && ( isActive || ! this . isPlaying ) ) {
718734 curPos += this . lyricLinesSize . get ( lineObj ) ?. [ 1 ] ?? 0 ;
719735 } else if ( ! line . isBG ) {
720736 curPos += this . lyricLinesSize . get ( lineObj ) ?. [ 1 ] ?? 0 ;
721737 }
722738 if ( curPos >= 0 && ! this . isSeeking ) {
723739 if ( ! line . isBG ) delay += baseDelay ;
724- // if (i >= this.scrollToIndex - 1) baseDelay *= 1.05;
725- // baseDelay = Math.min(baseDelay, 0.055);
726-
727- // delay += 0.05;
728740
729- // baseDelay = baseDelay > 0.15 ? 0 : baseDelay;
730- // delay = (i - this.scrollToIndex) * 0.06;
731741 if ( i >= this . scrollToIndex ) baseDelay /= 1.05 ;
732- // baseDelay = Math.max(baseDelay, 0.04);
733742 }
734743 } ) ;
735744 this . scrollBoundary [ 1 ] = curPos + this . scrollOffset - this . size [ 1 ] / 2 ;
@@ -781,17 +790,26 @@ export abstract class LyricPlayerBase
781790 }
782791 }
783792 }
793+ protected isPlaying = true ;
784794 /**
785- * 暂停部分效果演出,目前会暂停播放间奏点的动画
795+ * 暂停部分效果演出,目前会暂停播放间奏点的动画,且将背景歌词显示出来
786796 */
787797 pause ( ) {
788798 this . interludeDots . pause ( ) ;
799+ if ( this . isPlaying ) {
800+ this . isPlaying = false ;
801+ this . calcLayout ( ) ;
802+ }
789803 }
790804 /**
791805 * 恢复部分效果演出,目前会恢复播放间奏点的动画
792806 */
793807 resume ( ) {
794808 this . interludeDots . resume ( ) ;
809+ if ( ! this . isPlaying ) {
810+ this . isPlaying = true ;
811+ this . calcLayout ( ) ;
812+ }
795813 }
796814 /**
797815 * 更新动画,这个函数应该被逐帧调用或者在以下情况下调用一次:
0 commit comments