iTunes的脚本桥接显示不起作用 [英] iTunes Scripting Bridge reveal does not work

查看:227
本文介绍了iTunes的脚本桥接显示不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下code应显示在iTunes一定轨迹:

The following code should show a certain track in iTunes:

NSString* iTunesPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.iTunes"];

iTunesApplication *iTunes = nil;
if ( iTunesPath ) {
 iTunes = [[SBApplication alloc] initWithURL:[NSURL fileURLWithPath:iTunesPath]];
 [iTunes setDelegate:self];
}

iTunesSource *librarySource = nil;
NSArray *sources = [iTunes sources];
for (iTunesSource *source in sources) {
 if ([source kind] == iTunesESrcLibrary) {
  librarySource = source;
  break;
 }
}
SBElementArray *libraryPlaylist = [librarySource libraryPlaylists];
iTunesLibraryPlaylist *iTLibPlaylist = nil;
if ([libraryPlaylist count] > 0) {
 iTLibPlaylist = [libraryPlaylist objectAtIndex:0];
}


SBElementArray *fileTracks = [iTLibPlaylist fileTracks];

iTunesFileTrack *track = [fileTracks objectAtIndex:4];
NSLog(@"Try to reveal track: %@ at path :%@",[track description],[[track location] path]);
[track reveal];

输出:

Try to reveal track: <ITunesFileTrack @0x1364ed20: ITunesFileTrack 4 of ITunesLibraryPlaylist 0 of ITunesSource 0 of application "iTunes" (2474)> at path :/Users/...

但绝对指出发生。我究竟做错了什么?
(iTunes的版本:9.0.3)

But absolutely noting happens. What am I doing wrong? (iTunes Version: 9.0.3)

推荐答案

图书馆播放列表不会在UI存在了;它的存在在模型中,因此它显示在AppleScript的,而是试图揭示它或任何东西在UI都不会做,因为你看到的。您可以在AppleScript的复制本,以及(显示源库播放列表1中的轨道5 1 )。

The Library playlist doesn't exist anymore in the UI; it's there in the model, so it shows up in AppleScript, but trying to reveal it or anything in it won't do anything in the UI, as you saw. You can reproduce this in AppleScript as well (reveal track 5 of library playlist 1 of source 1).

解决方案是聊到音乐播放列表,而不是库的播放列表。 乐是第二个播放列表 - 播放列表2 中的AppleScript, [librarySource播放列表] objectAtIndex:1] 可可

The solution is to talk to the Music playlist, not the Library playlist. "Music" is the second playlist—playlist 2 in AppleScript, [[librarySource playlists] objectAtIndex:1] in Cocoa.

如果您想揭示一个播放项目无论播放它的演奏中,使用显示当前曲目(这应该是 [iTunes的currentTrack]揭示] ,虽然我没有测试过)。

If you want to reveal a playing item in whatever playlist it's playing in, use reveal current track (which should be [[iTunes currentTrack] reveal], although I haven't tested that).

这篇关于iTunes的脚本桥接显示不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆