使用iTunes的上一步功能与API [英] Use iTunes' Up Next function with an API

查看:138
本文介绍了使用iTunes的上一步功能与API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用iTunes的上一步功能与API?



我知道你可以使用脚本桥,但它不覆盖任何iTunes 11的新功能。

解决方案

iTunes没有公共API,但脚本桥



你可以使用Applesript UI脚本我会打赌 - 但是这将是非常脆弱的



你也可以模拟一个按键,然后: >
比编写可见界面(IMO)更脆弱:

http://hints.macworld.com/article.php?story=20121203223100335 / p>

TADA - YAY - 一个准备脚本,将添加选择的歌曲到UpNext ::

 告诉应用程序AppleScript Utility
设置GUI脚本启用为真
end tell

告诉应用程序iTunes
--get歌曲
设置l到播放列表已购买
设置t到l的轨道的项目5

- 将其列在列表
显示t

--show window
activate
end tell

告诉应用程序系统事件
- 选项输入
延迟1
键下选项
延迟1
键代码36
键向上选项

- 单击恼人对话框中的播放歌曲按钮。
设置w为null
尝试
设置w到应用程序iTunes的窗口添加到下一步
结束尝试
如果w不为null,则
设置b的UI元素播放歌曲的w
点击b
end if
end tell


Is there a way to use iTunes' Up Next function with an API?

I know that you can use Scripting Bridge, but it doesn't cover any of the new functions of iTunes 11.

解决方案

iTunes has no public API but the scripting bridge

you could use Applesript UI Scripting I'd wager -- but that would be very fragile

you can also simulate a keypress then:
That less fragile than scripting the visible interface (IMO):
http://hints.macworld.com/article.php?story=20121203223100335

TADA -- YAY -- a 'ready' script that will add songs selected to UpNext ::

tell application "AppleScript Utility"
    set GUI Scripting enabled to true
end tell

tell application "iTunes"
    --get the song
    set l to playlist "Purchased"
    set t to item 5 of tracks of l

    --focus it in list
    reveal t

    --show window
    activate
end tell

tell application "System Events"
    -- option enter
    delay 1
    key down option
    delay 1
    key code 36
    key up option

    -- Click the "Play Song" button in the annoying dialog.
    set w to null
    try
        set w to window "Add to Up Next" of application process "iTunes"
    end try
    if w is not null then
        set b to UI element "Play Song" of w
        click b
    end if
end tell

这篇关于使用iTunes的上一步功能与API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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