java - 如何使用 Applescript 和 Java 在 iTunes 中播放歌曲预览?
问题描述
我经常使用 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, …};
推荐阅读
- flutter - 带有 StreamBuilder 的 TextField 的初始值
- typescript - 如何根据参数中的函数返回类型指定打字稿条件类型
- peoplesoft - PeopleSoft 子查询没有选择正确的休假计划
- c# - 限制 NUnit 项目中的并行线程数
- swift - Cocoapod 中的 CoreML(pod 规范 lint 不起作用)
- javascript - 我用“JS原型”编写的用户输入代码不起作用
- c# - 我应该怎么做才能显示获得有利数字需要多少循环?
- python - 自定义类的 Sklearn 管道持久性不起作用
- office-js - Word OfficeJS for Office 2016 和 WordOnline 中的通配符搜索不起作用
- javascript - 一个很好的 vue 网格替代方案,而不是使用 vue 无限加载器