Skip to content

CodeSnip: Getting Currently Playing info from Windows Media Player using the blogging power toy.

Thu Sep 23 2004

I don't know whom this would benefit but someone building a blog posting tool for the desktop, but anyway here's the code that I converted from the jscript example that comes with the Windows Media Player bloggingpowertoy :

 System;
 Microsoft.Win32;

  MediaPlayerInfo
	{

		   GetCurrentlyPlayingMedia(){
			RegistryKey regKey = Registry.CurrentUser;
			regKey = regKey.OpenSubKey();

			 displayString = ;

			 hasMetadata = ;

			 trackInfo = ;

			{
				trackInfo = regKey.GetValue().ToString();

				(trackInfo.Length != 0){
					hasMetadata = ;

					displayString += trackInfo + ;
				}
			}{
				{
					trackInfo = ;
					trackInfo = regKey.GetValue().ToString();

					(trackInfo.Length != 0){
						hasMetadata = ;

						displayString += trackInfo + ;
					}
				}{}
			}

			{
				trackInfo = ;
				trackInfo = regKey.GetValue().ToString();

				(trackInfo.Length != 0){
					hasMetadata = ;

					displayString +=  + trackInfo + ;
				}
			}{}

			{
				trackInfo = ;
				trackInfo = regKey.GetValue().ToString();

				(trackInfo.Length != 0){
					hasMetadata = ;

					displayString +=  + trackInfo;
				}
			} {}

			{
				trackInfo = ;
				trackInfo = regKey.GetValue().ToString();

				(trackInfo.Length != 0){
					hasMetadata = ;

					displayString +=  + trackInfo;
				}
			}{}


			(!hasMetadata){
				displayString += ;
			}

			displayString += ;

			 displayString;
		}
	}

It could probably stand to be a bit more flexible - ie user-defined by a template like w.bloggar, but for the basics it works great! Oh yeah, and let's not forget the output:

[ Currently Listening to: Rage Against The Machine - Pocket Full of Shells (03:52) ]

💾 May the source be with you. v3.2.419