Use iTunes' Up Next function with an API

笑着哭i 提交于 2019-12-22 04:36:22

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/13659626/use-itunes-up-next-function-with-an-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!