MCPcopy
hub / github.com/iChochy/NCE / handleSentenceLoop

Method handleSentenceLoop

js/ReadingSystem.js:545–571  ·  view source on GitHub ↗

* 处理单句循环

()

Source from the content-addressed store, hash-verified

543 * 处理单句循环
544 */
545 handleSentenceLoop() {
546 if (
547 this.state.loopMode == 'list' ||
548 !this.dom.audioPlayer ||
549 this.state.currentLyricIndex === -1
550 ) {
551 return;
552 }
553
554 const duration = this.dom.audioPlayer.duration;
555 const currentTime = this.dom.audioPlayer.currentTime;
556 const currentLyrics = this.state.currentLyrics;
557 const currentLyricIndex = this.state.currentLyricIndex;
558
559 const boundaries = LRCParser.getSentenceBoundaries(currentLyrics, currentLyricIndex, duration);
560 if (!boundaries) return;
561
562 if (currentTime >= boundaries.endTime) {
563 // 验证 startTime 是否为有效的有限数值
564 if (Number.isFinite(boundaries.startTime)) {
565 this.dom.audioPlayer.currentTime = boundaries.startTime;
566 if ( this.state.loopMode == 'off') {
567 this.dom.audioPlayer.pause();
568 }
569 }
570 }
571 }
572
573 // =========================================================================
574 // 音频播放控制

Callers 1

bindPlayerControlsMethod · 0.95

Calls 1

getSentenceBoundariesMethod · 0.80

Tested by

no test coverage detected