APlayer icon indicating copy to clipboard operation
APlayer copied to clipboard

Adding offset to lyrics dynamically / 动态调整LRC歌词偏移延迟

Open rakuzen25 opened this issue 3 years ago • 2 comments

I know I can preprocess the LRC file and adjust the timing before loading into APlayer, but I'm wondering if it's possible to change the lyrics offset on the fly without reloading the song.

For example, I'd like to do something like lrc.setOffset(1000) to +1000ms for each line.

rakuzen25 avatar Oct 12 '22 12:10 rakuzen25

One solution I'm thinking of is to use the timeupdate event:

player.on("timeupdate", () => {
    player.lrc.update(player.audio.currentTime + offset);
});

But still feels a bit weird…

rakuzen25 avatar Oct 12 '22 13:10 rakuzen25

不知是否有办法定义下面的这个滚动高度呢?16 → 80

{
        key: "update",
        value: function () {
          var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this.player.audio.currentTime;
          if (this.index > this.current.length - 1 || e < this.current[this.index][0] || !this.current[this.index + 1] || e >= this.current[this.index + 1][0])
            for (var t = 0; t < this.current.length; t++) e >= this.current[t][0] && (!this.current[t + 1] || e < this.current[t + 1][0]) && (this.index = t, this.container.style.transform = "translateY(" + 16 * -this.index + "px)", this.container.style.webkitTransform = "translateY(" + 16 * -this.index + "px)", this.container.getElementsByClassName("aplayer-lrc-current")[0].classList.remove("aplayer-lrc-current"), this.container.getElementsByTagName("p")[t].classList.add("aplayer-lrc-current"))
        }
      },

yife68 avatar Dec 09 '23 16:12 yife68