iTunes 通讯。如何使用 C# 获取曲目的旧位置?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当找到文件时,“where”值显示
C:\...
但当未找到文件时,它显示file:\\C:\...
code> 在 iTunes 中,并且在代码中,您可以使用 Location 属性访问位置(您的代码可能存在错误 - 将“Location”中的“L”大写)来自 SDK 文档:
我能够重现这一点(即,当找不到文件时,在 itunes 中查看“where”值,并从 IITFileOrCDTrack.Location 返回 null。
我不认为它是除非它是未记录,如果找不到实际文件,则不可能返回该值。When the file is found, the "where" value shows
C:\...
but when the file is not found, it showsfile:\\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:
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 isUnless it is undocumented, it is not possible to return the value if the actual file cannot be found.