c# - iTunes COM。如何使用 C# 获取轨道的旧位置?

标签 c# itunes-sdk

iTunes 有轨道的旧位置(不再存在的文件路径)!在他们面前。我知道这一点,因为如果您右键单击轨道!在它前面并选择 GetInfo(然后选择否,不定位它)。在摘要选项卡下,它有一个部分显示歌曲的路径(不工作)。当我尝试使用 iTumes COM 获取轨道位置时,IITFileOrCDTrack.location 返回空字符串。那么,如何从 Getinfo --> Summary 选项卡中获取这个“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.

最佳答案

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

来自 SDK 文档:

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.

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

关于c# - iTunes COM。如何使用 C# 获取轨道的旧位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4834419/

相关文章:

C#、Metro、Stream Socket、SSL 不可信主机、Squid

c# - 密码框和 MVVM

JavaScript 问题 : How to Convert Hexadecimal Number to High and Low 32-bit values

python - iTunes win32com Python - AddTrack 不起作用

python - 适用于 Windows SDK 的 iTunes COM 中的媒体种类

c# - 在不消耗内存的情况下运行连续的 Windows 后台任务

c# - MVC 5 - DataAnnotations 的默认消息和本地化(电子邮件、Url 等)

C# MYSQL Insert 查询无法更新或添加子行

c# - 在类/子类中使用 Content.Load<>

C# iTunesLib com : AlbumArtist member not accessible with intellisense