![](/img/trans.png)
[英]Found an iTunes Controller API for Java, how can I play a specific song?
[英]How can I play a song preview in iTunes using Applescript and Java?
我一直在使用iTunes API來搜索歌曲,我希望用戶能夠選擇一個選項來在iTunes中播放歌曲預覽。
當前,以下內容將僅打開iTunes:
public class PlayMedia {
public PlayMedia()
{
Runtime runtime = Runtime.getRuntime();
String[] args = { "osascript", "-e", "tell application \"iTunes\" to play"};
try
{
Process process = runtime.exec(args);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
public static void main(String[] args) throws IOException, JSONException {
new PlayMedia();
}
我該如何擴展以傳遞歌曲ID /標題?
String[] args = {"osascript", "-e", "on run {arg1, arg2,…}",
"-e", " tell application \"iTunes\" to …",
"-e", "end run",
"--",
arg1, arg2, …};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.