Skip to content

✨ feat: 支持AB循环#794

Merged
imsyy merged 4 commits into
devfrom
dev-cy
Feb 1, 2026
Merged

✨ feat: 支持AB循环#794
imsyy merged 4 commits into
devfrom
dev-cy

Conversation

@kazukokawagawa
Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kazukokawagawa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求引入了一个全新的AB循环功能,允许用户在音频播放中定义一个循环区间。通过新增的UI组件和播放器集成,用户可以方便地设置和管理循环点,从而实现对音频特定片段的重复播放。此功能增强了播放器的实用性,特别适用于需要反复聆听特定段落的场景,如语言学习或音乐练习。

Highlights

  • 新增AB循环功能: 引入了AB循环模式,允许用户设置音频的起点A和终点B,并在播放到达B点时自动跳回A点,实现指定区间的循环播放。
  • 独立的AB循环组件: 创建了ABLoop.vue组件,提供了用户界面来启用/禁用AB循环,设置/清除A、B点,并支持对时间点进行微调。
  • 播放器集成: 在播放器的右键菜单中添加了“AB 循环”选项,方便用户快速访问和控制此功能。
  • 状态管理与播放控制: 在全局状态管理中增加了abLoop对象,用于存储AB循环的启用状态以及A、B点的时间。同时,在播放控制器中实现了AB循环的播放逻辑,并在新歌曲播放时自动重置循环状态。
  • 自动校验与禁用: 系统会校验A、B点的有效性,确保B点晚于A点,并在不符合条件时自动禁用循环,以防止不正确的循环行为。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 很好地实现了 AB 循环功能。整体代码结构清晰,功能点覆盖全面。我在 ABLoop.vue 组件中发现了一些可以改进的地方,主要关于代码重构和 UI 文本的准确性,并提供了一些具体的代码建议。请查看我的评论。

Comment on lines +84 to +86
<n-text depth="3" style="font-size: 12px">
提示:若 B 点小于 A 点,循环将不会生效。
</n-text>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里的提示文本可以更精确一些。根据代码逻辑,当 B 点等于 A 点时,循环同样不会生效。建议将提示修改为“小于或等于”,以避免用户困惑。

    <n-text depth="3" style="font-size: 12px">
      提示:若 B 点小于或等于 A 点,循环将不会生效。
    </n-text>

Comment on lines +111 to +131
const setPoint = (point: "A" | "B") => {
const current = audioManager.currentTime;
if (point === "A") {
statusStore.abLoop.pointA = Number(current.toFixed(2));
// Auto disable if invalid
if (
statusStore.abLoop.pointB !== null &&
statusStore.abLoop.pointA >= statusStore.abLoop.pointB
) {
statusStore.abLoop.enable = false;
}
} else {
statusStore.abLoop.pointB = Number(current.toFixed(2));
if (
statusStore.abLoop.pointA !== null &&
statusStore.abLoop.pointA >= statusStore.abLoop.pointB
) {
statusStore.abLoop.enable = false;
}
}
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了提高代码的可维护性,可以对 setPoint 函数进行重构以消除重复的逻辑。在设置 A 点或 B 点后,检查循环有效性的逻辑是相同的。可以将其提取出来,使代码更简洁。

const setPoint = (point: "A" | "B") => {
  const current = audioManager.currentTime;
  if (point === "A") {
    statusStore.abLoop.pointA = Number(current.toFixed(2));
  } else {
    statusStore.abLoop.pointB = Number(current.toFixed(2));
  }
  // Auto disable if invalid
  const { pointA, pointB } = statusStore.abLoop;
  if (pointA !== null && pointB !== null && pointA >= pointB) {
    statusStore.abLoop.enable = false;
  }
};

@imsyy imsyy merged commit 1598747 into dev Feb 1, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants