About Me ·
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.
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:
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.
Download 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
a@href@title, blockquote@cite, em, strike, strong, sub, sup, u
Page rendered at Thursday, September 29, 2016 12:05:01 PM (W. Europe Daylight Time, UTC+02:00)
newtelligence dasBlog 2.3.257.0
© Copyright 2016, admin
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.