1

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.

Zebi
  • 8,682
  • 1
  • 36
  • 42

3 Answers3

1

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.

Wukerplank
  • 4,156
  • 2
  • 28
  • 45
  • TRAKTOR is a DJ software, Coq a simple music player like winamp. I am taking a look at itunes-rails. – Zebi Apr 11 '11 at 12:26
0

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>
Sam Coles
  • 4,003
  • 24
  • 19
  • Thanks this should work. Cog provides AppleScript functions, as well as iTunes. TRAKTOR does not provide any API so I have to miss out on this programm. – Zebi Apr 15 '11 at 20:07
  • There's still a way to applescript applications that don't support it using the System Events framework. Here is a pointer: http://www.macosxautomation.com/applescript/uiscripting/index.html – Sam Coles Apr 15 '11 at 21:25
  • You should leave a link to video of this in action when it goes to "production". – Sam Coles Apr 15 '11 at 21:29
0

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