Skip to content

fix(mpv): 修复MPV播放UNC路径歌曲失败#1013

Merged
imsyy merged 3 commits intoimsyy:devfrom
577fkj:dev
Mar 28, 2026
Merged

fix(mpv): 修复MPV播放UNC路径歌曲失败#1013
imsyy merged 3 commits intoimsyy:devfrom
577fkj:dev

Conversation

@577fkj
Copy link
Copy Markdown
Contributor

@577fkj 577fkj commented Mar 24, 2026

修复本地音乐添加SMB共享(UNC路径)时候无法正常播放本地音乐

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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!

此拉取请求旨在解决MPV播放器无法正常播放来自SMB共享(UNC路径)的本地音乐文件的问题。通过引入一个通用的文件URL标准化工具函数,并优化MPV服务内部的路径处理逻辑,确保了不同格式的本地文件路径(包括UNC路径)都能被正确解析和加载,从而提升了本地音乐播放的兼容性和稳定性,尤其是在Windows环境下。

Highlights

  • 修复MPV播放UNC路径问题: 解决了MPV播放SMB共享(UNC路径)本地音乐失败的问题。
  • 引入文件URL标准化工具: 新增 toFileUrl 工具函数,用于统一生成 file:// 格式的URL,确保路径编码的正确性。
  • MPV服务路径处理优化: MpvService 现在使用 normalizeMpvLoadTarget 方法来处理各种文件URL格式,包括UNC路径,并将其转换为MPV可识别的本地路径格式,特别是在Windows系统上。
  • 统一文件路径生成: AutomixManagerSongManager 已更新,使用新的 toFileUrl 工具函数来生成文件URL,提高了路径处理的一致性。
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.

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 旨在修复 MPV 播放 UNC 路径下音乐文件失败的问题。通过在 MpvService 中添加 normalizeMpvLoadTarget 方法来正确处理和转换 file:// 协议的 URL,特别是针对 UNC 路径,这是一个正确的方向。同时,将文件路径到 URL 的转换逻辑提取到新的 toFileUrl 工具函数中,提高了代码的复用性。

我的审查意见主要集中在两个方面:

  1. 增强 toFileUrl 中路径编码的健壮性,以处理文件名中可能出现的特殊字符。
  2. MpvService 的错误处理逻辑中增加日志记录,以便于未来问题的排查。

整体来看,这是一个不错的修复,解决了描述中的问题。采纳建议后代码会更加健壮。

Comment on lines +500 to +503
} catch {
const rawPath = decodeURIComponent(url.slice("file://".length));
return this.normalizeLocalPath(rawPath);
}
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

针对 fileURLToPath(url) 的这个 catch 块同样抑制了错误。与上一个问题类似,在此处记录错误日志可以在 fileURLToPath 失败时提供有价值的诊断信息,同时不影响回退逻辑的执行。

    } catch (e) {
      processLog.warn(`[MpvService] 使用 'fileURLToPath' 解析 URL 失败,将执行回退逻辑: ${url}`, e);
      const rawPath = decodeURIComponent(url.slice("file://".length));
      return this.normalizeLocalPath(rawPath);
    }

imsyy and others added 2 commits March 28, 2026 23:40
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@imsyy imsyy merged commit 159f2e4 into imsyy:dev Mar 28, 2026
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