Ruby on Rails:获取媒体播放器信息(iTunes、TRAKTOR、Cog;当前歌曲和播放列表)

发布于 2024-10-31 15:25:24 字数 495 浏览 2 评论 0原文

我想编写一个小型 Web 应用程序来执行以下操作:

  • 提供一个网页来显示当前歌曲,一些元数据
  • 提供一个 Web api,可以查询下一首歌曲以允许页面更新而无需页面加载

没什么大不了的,我唯一无法估计的是是否可以访问 iTunes< 的当前歌曲/a>, TRAKTOR如果可能的话,来自 ruby​​ on Rails 应用程序的 Cog

如果我也可以访问播放列表并显示以下歌曲,那就太好了。

I want to write a small web app which does this things:

  • deliver a web page to display the current song and some meta data
  • provide a web api which can be queried for the next song to allow the page to update without page load

No big deal, the only part I can't estimate is if it's possible to access the current song of iTunes, TRAKTOR and if possible Cog from a ruby on rails application.

It would be especially nice if I can access the playlist, too to display the following song, too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

欢你一世 2024-11-07 15:25:25

我会通过命令行使用 applescript。我没有 Traktor Pro 或 Coq,但您可以通过 OS X 脚本编辑器中的 AppleScript 字典查看器查看可用的对象。对于 iTunes,命令为:

osascript -e 'tell application "iTunes" to get name of current track'
osascript -e 'tell application "iTunes" to get name of every track of current playlist'

您可以从 Rails 应用程序(需要以您的用户帐户运行)执行命令,如下所示:

def show
    @current_track = `osascript -e 'tell application "iTunes" to get name of current track'`
end

...

<h1>The current track is: <%= @current_track -%></h1>

I would use applescript via the command-line. I don't have Traktor Pro or Coq, but you can look at what objects are available via the AppleScript Dictionary viewer in OS X's Script Editor. For iTunes, the command would be:

osascript -e 'tell application "iTunes" to get name of current track'
osascript -e 'tell application "iTunes" to get name of every track of current playlist'

You would execute the command from your rails app (which would need to be running as your user account) like this:

def show
    @current_track = `osascript -e 'tell application "iTunes" to get name of current track'`
end

...

<h1>The current track is: <%= @current_track -%></h1>
迷迭香的记忆 2024-11-07 15:25:25

Traktor 只能通过两种方式访问​​名称:

  • 从其 Icecast 广播中捕获数据,
  • 使用变通方法

方法是欺骗它认为已连接恶魔设备,捕获 MIDI 输出数据并通过此 JavaScript https://github.com/Sonnenstrahl/traktor-now-playing

Traktor you can only access the names via two ways:

  • capturing data from its ice cast broadcast
  • using a work around by tricking it into thinking a demon device is connected, capturing the MIDI output data and converting via this JavaScript

https://github.com/Sonnenstrahl/traktor-now-playing

我爱人 2024-11-07 15:25:24

我从来没有听说过你提到的另外两个播放器,但是有了 iTunes,这绝对是可能的。例如,看看这个项目:http://code.google.com/p/itunes-rails /

应该有一个可以与 iTunes 通信的脚本桥。不过不确定其他球员的情况。

I've never even heard of the other two players you are mentioning, but with iTunes this is definitely possible. Look at this project for example: http://code.google.com/p/itunes-rails/

There should be a scripting bridge that can communicate with iTunes. Not sure about the other players, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文