Click here to Skip to main content
13,356,787 members (58,030 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 8 Dec 2005

A Winamp Front-End Library with C#

, 8 Dec 2005
Rate this:
Please Sign up or sign in to vote.
An article on a C# library responsible for acting as a Winamp front-end
Demo screenshot - demoScreenshot.png


This is a rather basic C# class for controlling Winamp via the classic Win32 Message API. I guess you can say it's a front-end to Winamp capable of supporting the most common commands one would want to implement from within a .NET enabled application.

It's been some time now that I've wanted to incorporate some basic Winamp functionality into a C# application of mine, and the need for establishing communication between the .NET environment and Winamp came up. I started searching the net for any available libraries or code samples, but without much luck or a completed example. I soon noticed that a Winamp SDK was made available to C developers from its official website. This was when I realized that the best option for me (in order to keep things simple for my C# application) was to translate the main part of the SDK to a C# version.

Having said all these, if you still want to "master" Winamp through your C# application, then read on. 


First of all, let me say that this is not entirely my own work, meaning that I didn't write this code from scratch. It is just a C# translation of the C version official Winamp SDK. More detailed, in order to come up with this code I used the following references:

  • A rather useful Geekpedia tutorial covering all the basics for setting up the communication with Winamp from the .NET environment
  • The Winamp 5 SDK
  • Some constants were also taken from:
    1. The "wa_ipc.h" header file located in the Winamp SDK
    2. This header file
  • Methods "GetCurrentSongTitle()" and "IsNumeric()" were adapted from this CodeProject article

Just to give you an idea, a nice real-life example where a similar front-end is incorporated are sidebars (e.g.  Google Desktop's sidebar, or DesktopSidebar). These are vertical/horizontal bars docked on any screen edge of your desktop which contain a number of customizable useful stuff; news feeds, your photos, weather information, and of course basic Winamp/Windows Media Player control-capabilities. 

Basic Introduction to Winamp Command Types

This front-end class contains only static methods. This makes it much easier to directly call any number of methods from the class without having to construct any number of objects beforehand.

The code makes heavy use of the Win32 Message API so the relevant DLLs are imported and used throughout the methods in the class. When it comes to the communication with Winamp, I've noticed that there are two basic categories of command types that are used in order to send and/or receive an amount of information to/from Winamp;

  2. WM_USER (might be also known as WM_WA_IPC)

The first type of command is used for the main Winamp operation that has to do with its primary functionalities; such as Play(), Stop(), Pause(), etc. They are used to send a specific command to Winamp and return nothing back to the calling program. The second type of command is used for secondary operations able to return some basic information back to the program; such as GetPlaybackStatus() etc. Within C#, these two command types have to be represented by a specific hex code like this:

// To tell Winamp that we are sending it a WM_COMMAND it needs the hex code 0x111
const int WM_COMMAND = 0x111; 

// To tell Winamp that we are sending it a WM_USER (WM_WA_IPC) 
// it needs the hex code 0x0400
const int WM_WA_IPC = 0x0400;

Using the Code

The first thing to do is to locate the WinampFrontEndLib.dll library file and add it into your app's reference section. I know that most probably you've done this process a million times but yet, I feel the urge to mention how it's done:

  1. Right-click on your C# project (in the Solution Explorer window) and click on the "Add Reference..." menu item
  2. From the "Add Reference" dialog, click on the "Browse" button (after you make sure that you are on the .NET tab)
  3. Navigate to the folder in which you stored the source files that you downloaded from here, locate the WinampFrontEndLib.dll library file from the WinampFrontEndLib\bin\Release folder and double-click on it
  4. If you've done everything right, you should now be presented with the dialog box below. If you are, then hit "OK":

Add Reference screenshot- AddReference.jpg

Now just add the relevant namespace in your using section and you are ready to go:

// Do not forget to include the necessary namespace
using WinampFrontEndLib;

Since everything in the Winamp class is declared as static, using its methods is quite straight-forward. The following example demonstrates the click event for the play button in the demo application:

private string DisplaySong()
    return WinampLib.GetCurrentSongTitle();

private void button1_Click(object sender, System.EventArgs e)
    this.lblTitle.Caption = this.DisplaySong();

The same goes with the click events of the volume up/down buttons in the demo:

private void button6_Click(object sender, System.EventArgs e)

private void button3_Click(object sender, System.EventArgs e)

I guess you pretty much figured out how easy it is to call these methods from your app by now. The same logic goes with the rest of the available methods in the class.

Using the Demo

An executable demo is also included in the zip files available for download. This is a tiny project that demonstrates the use of some of the most common Winamp commands, and the ease of calling the various methods of the library. In order to use it, there is only one prerequisite; just launch Winamp. You can then start playing around with the demo app. (I really like watching the volume bar in Winamp moving by itself while clicking on the Volume up/down buttons on the C# demo :)). 

Current Limitations (and Possibly Future Development) of the Winamp Front-end

  1. The library establishes only basic communication between your application and Winamp by sending commands to a running instance of it. What I mean is that Winamp must be installed and running if you actually want to get this thing to work at all. So don't wonder what's going on if nothing happens when you execute any method of the library without having Winamp running in the background.
  2. The current version does not include any methods for launching Winamp if it's not already running. This can be easily done by adding a few lines of code if you want to. So please feel free to alter the code in order to suit your needs.
  3. The current version is also incapable of hiding a running instance of Winamp, or whatsoever. I guess that if you manage to do so, your users could get the impression that they are actually controlling Winamp 100% through your app.


  • 8th December, 2005 - Version 1.0


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Polis Pilavas
Web Developer
Cyprus Cyprus
Simpsons' fanatic.

You may also be interested in...


Comments and Discussions

AnswerGetCurrentVolume Pin
Tsuushin31-May-09 19:15
memberTsuushin31-May-09 19:15 
GeneralRe: GetCurrentVolume Pin
cybie042-Jun-09 11:08
membercybie042-Jun-09 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 8 Dec 2005
Article Copyright 2005 by Polis Pilavas
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid