Contact

admin

About Me · Send mail to the author(s) E-mail · Twitter

At GROSSWEBER we practice what we preach. We offer trainings for modern software technologies like Behavior Driven Development, Clean Code and Git. Our staff is fluent in a variety of languages, including English.

Feed Icon

Tags

Open Source Projects

Archives

Blogs of friends

Now playing [?]

Error retrieving information from external service.
Audioscrobbler/Last.fm

ClustrMap

Now Playing 1.0

Posted in Music | Now Playing at Tuesday, August 16, 2005 11:25 PM W. Europe Daylight Time

I am a lazy person. As a (every?) developer I want to relieve users from cumbersome tasks that recur often enough to justify an automated solution.

So it is with the cumbersome assembly of the "Now Playing" line on the end of each post I introduced in my first blog entry. I want to let it consist of the following elements:

  • A prefix, "Now Playing: " in my case,
  • The artists of the currently playing track,
  • The album (if any) of the currently playing track,
  • The title of the currently playing track.

The artists fragment should be linked to Music-Map as this service shows a nice overview of artists/bands other people liked - a great way to figure out if you may like that kind of music. The album part should be linked to Amazon so you can dig into the details of the CD and listen to samples. Links should only be added if there's such information available, of course.

The three times I've put together the "Now Playing" line manually showed me that this is definitely such a recurring task. After two days Now Playing 1.0 is ready for take-off. It tells my favorite music player to get the aforementioned info of the currently playing item, queries Music-Map and Amazon's Web Services for the links and assembles the resulting HTML markup.

The application is entirely written in C#. For pulling the track info out of the music player there were little tricks needed: Winamp doesn't support giving the info to out-of-process components so a plugin would be the easiest way to retrieve the info and hand it over to another application through some IPC mechanism. In contrast to that, my goal was to create a solution that's not depended on plugins. After some research I found that VirtualAllocEx() is able to reserve memory in a foreign process. ReadProcessMemory() and WriteProcessMemory() are the functions to manipulate such a memory region. All I needed to do was to set up the query structure in such a way that it resides in Winamp's address space and send the query-track-info message to its main window. Winamp happily writes the desired results into "my" memory in its own address space. After reading them and freeing the block of memory I can go on with the web queries.

As always when working with Platform Invoke, www.pinvoke.net and their VS.NET Add-In was a great help.

DownloadDownload the binaries. Have a look at the NowPlaying.exe.config file as you will need to enter you Amazon Developer Subscription ID (create one here). The string/HTML fragments are stored there too.

Here's the result of the first usage in production mode:

Now playing: Aimee Mann - Lost in space - Lost in space

Thursday, August 25, 2005 3:27:33 PM (W. Europe Daylight Time, UTC+02:00)
Unbelievable... You're the man!!!
All comments require the approval of the site owner before being displayed.
(will show your gravatar icon)
 
[Captcha]Enter the code shown (prevents robots):

Live Comment Preview