iTunes 通讯。如何使用 C# 获取曲目的旧位置?

发布于 2024-10-14 17:51:02 字数 596 浏览 1 评论 0原文

iTunes 具有曲目的旧位置(不再存在的文件路径)!在他们面前。我知道这一点是因为如果你右键单击轨道!并选择 GetInfo(然后选择否,不要找到它)。在“摘要”选项卡下,有一个部分显示歌曲的路径(不起作用)。当我尝试使用 iTumes COM 获取曲目位置时,IITFileOrCDTrack.location 返回空字符串。那么,我如何从 Getinfo 获取这个“where”值 -->摘要选项卡?

以下是我目前尝试获取轨迹位置的方法(使用 C#)。我的整个 iTunes 库有 10 首歌曲,所有这些歌曲都指向错误的文件位置,因此我选择哪首歌曲并不重要。

iTunesApp itunes = new iTunesApp(); 
IITLibraryPlaylist mainLibrary = itunes.LibraryPlaylist;
IITTrackCollection tracks = mainLibrary.Tracks;
IITFileOrCDTrack currTrack;
currTrack = tracks[5] as IITFileOrCDTrack;
Console.WriteLine(currTrack.location) //output is blank.

iTunes has the old location (file path that no longer exist) of track with ! in front of them. I know this because if you right click on track with ! in front of it and select GetInfo (then choose no, don't locate it). Under Summary tab it has a section that shows the song's path (not working). when I try to get the track location using iTumes COM, IITFileOrCDTrack.location return empty string. So, how do I get this "where" value from Getinfo --> Summary tab?

Below is how I currently try to get track location (using C#). My entire iTunes lib has 10songs all of them point to the wrong file location so it doesn't matter which song I chose.

iTunesApp itunes = new iTunesApp(); 
IITLibraryPlaylist mainLibrary = itunes.LibraryPlaylist;
IITTrackCollection tracks = mainLibrary.Tracks;
IITFileOrCDTrack currTrack;
currTrack = tracks[5] as IITFileOrCDTrack;
Console.WriteLine(currTrack.location) //output is blank.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小霸王臭丫头 2024-10-21 17:51:02

当找到文件时,“where”值显示 C:\... 但当未找到文件时,它显示 file:\\C:\... code> 在 iTunes 中,并且在代码中,您可以使用 Location 属性访问位置(您的代码可能存在错误 - 将“Location”中的“L”大写)

来自 SDK 文档:

HRESULT 位置([out, retval] BSTR *位置)

返回该曲目所代表的文件的完整路径。

参数:
location 返回该轨道所代表的文件的完整路径。

返回值:

S_OK 操作成功。
S_FALSE 无法检索位置(例如,预期位置不存在文件)。
E_POINTER 位置为 NULL
ITUNES_E_OBJECTDELETED 该曲目已被删除。
E_FAIL 发生意外错误。

我能够重现这一点(即,当找不到文件时,在 itunes 中查看“where”值,并从 IITFileOrCDTrack.Location 返回 null。我不认为它是除非它是未记录,如果找不到实际文件,则不可能返回该值。

When the file is found, the "where" value shows C:\... but when the file is not found, it shows file:\\C:\... within iTunes, and from the code, you can access the location by using the Location property (a bug perhaps, with your code - capitalize the 'L' in 'Location')

From the SDK documentation:

HRESULT Location ([out, retval] BSTR *location)

Returns the full path to the file represented by this track.

Parameters:
location Returns the full path to the file represented by this track.

Return values:

S_OK The operation was successful.
S_FALSE The location could not be retrieved (e.g. no file exists at the expected location).
E_POINTER location is NULL.
ITUNES_E_OBJECTDELETED This track has been deleted.
E_FAIL An unexpected error occurred.

I was able to reproduce this (i.e. see the "where" value in itunes, when the file cannot be found, and get null returned from IITFileOrCDTrack.Location. I don't think it is Unless it is undocumented, it is not possible to return the value if the actual file cannot be found.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文