Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rakuzen25 opened this issue Oct 12, 2022 · 2 comments
Open

Comments

@rakuzen25
Copy link

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
Copy link
Author

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…

@yife68
Copy link

yife68 commented Dec 9, 2023

不知是否有办法定义下面的这个滚动高度呢?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"))
        }
      },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants