Daily Archives: 17 - Aug - 2004

Fun with JuK and DCOP

After reading Ian Geiser’s recent post admiring the DCOP functionality in JuK, I thought it would cool if I elaborated a bit about what would be nice about it.

First of all, some of the things that you can do with JuK through DCOP include:

  • Add files to a given playlist.
  • List the tracks in a playlist.
  • List all the playlists.
  • Create a new playlist.
  • Remove a track from the playlist.
  • Remove a playlist.
  • Set the current playlist.
  • You CAN’T remove a track from disk through DCOP. Scott and I judged that this is too risky for potential abuse or mistakes.
  • Find out the track that’s playing.
  • Get/set the volume.
  • Get/set the player status.
  • The basics (stop, play, pause, next, forward, seeking).

However, what’s REALLY cool is that you can query information about a given track. And the interface is mostly future-proof. You can make a DCOP call to see what properties JuK can query. And Ian Geiser just added two more properties the other day, using 2 lines of code. Which is what I think he was happy about.

During the development process for KDE 3.3, Scott and I came up with a way to easily add properties in the JuK code, using *GASP* macros. Since so much of the property code was the same ol’ boilerplate, we setup a system of macros and a map of property names to auto-generated classes to return the property value. This means that with ONE line of code, we can add a property to the DCOP property map. Pretty neat, huh?

Just for completeness, as of now in CVS HEAD, the currently defined properties for a track are as follows:

  • Album
  • Artist
  • Bitrate
  • Comment
  • Extension — This is the extension of the track’s file name, added by Ian.
  • Genre
  • Path — This is the absolute file path of the track.
  • Seconds
  • Size — Added by Ian
  • Title
  • Track
  • Year