How would i play a specific song in iTunes through

2019-07-26 07:43发布

问题:

How would i play a specific song in iTunes through java?

I assume I need to somehow connect to iTunes and use the play function with a certain parameter....Can anyone point me in the right direction to learning how to do this?

回答1:

According to that answer, there is no API. There is only an SDK (via COM) for Windows. In Mac OS, iTunes is controlled via AppleScript(example).



回答2:

Ik it's too late, but u can use apple script editor. for instance,

Runtime runtime = Runtime.getRuntime();
                String[] args = {"osascript" , "-e" , "tell application \"iTunes\" to play"};
                try{
                Process process = runtime.exec(args);
                }catch (Exception ex) {                 
                }

this will play a song in itunes