Thursday, June 26, 2008

Windows Media Player (and Center) library interface for .NET

I have had a few problems learning how to do stuff with Windows Media Center.
The API is ok, but its by no means complete and as such really restricts the amount you can do with it.
Its a start, and somewhere somehow the tools are there to let you do what you want with Windows, its just a matter of how hard you want to work.

I wanted a way to programmatically access the music library for Windows Media Center for an application I am developing. After crawling through forums and API's I soon worked out it just wasnt going to happen... but something obvious occured to me: The Media Center library is just freaking Media Player! Media Center is just a glorified (and pretty sweet) front end for WMP.

So I spent some time medling with getting access to the WMP SDK from Visual Studio Express 2008 in C#. It was REALLY easy, but here is a crash course.

Grab your self some Windows Media Player SDK if you want, but I am really not sure that you need it anymore.

Make a new C# (or what ever language you like) project. Right click on the References and Add Reference. We want a COM object, and its quite simple Windows Media Player which links right to the wmp.dll.
All you need in code then is a "using WMPLib" or what ever the include work is for your language.

Let me point out here that I am UBER impressed with how easy it is to include COM objects in to managed code. Really very cool.

Forgive me, at this moment I have no idea how to put code into the blog with styles so its going to be a bit crappy to look at.

You are going to need a few objects to do work with. First is a WindowsMediaPlayer object.

WindowsMediaPlayer player = new WindowsMediaPlayer();


So you want access to all your music? Ok, easy.


IWMPPlaylist playList = Player.mediaCollection.getByAttribute("MediaType", "audio");

Simple! Just bounce through that big list of music and do what you want. All the properties and attributes of the files are accessed through the IWMPMedia class by invoking a getItemInfo.

IWMPMedia = playList.get_item(i); // i am obviously doing this in a loop arent I :-)
string artist = currentMedia.getItemInfo("DisplayArtist");


I cant remember how I worked out what the item tags were called, but I think I just looked at the inside of the IWMPMedia through the debugger.
"Title" is another useful attribute you might want to query.

What if I wanted to play this song in Media Center you ask? Easy. I won't go through the in's and out's of the Media Center API, but just get the location of the song via "currentMedia.sourceURL" and pass that to WMC's PlayMedia method.

I hope I have helped someone out with this info

Wednesday, June 18, 2008

Oops, thats what a Flog is

I just learnt of this: Fake Blog

Flog is also a Fake Blog... this is not one of those.

Pwned

Tuesday, June 17, 2008

Intel Storage Matrix FTL

Intel Storage Matrix For The Lose....
I have had limited experience with Intel Storage Matrix... I started off thinking I was impressed but now not so much.

The setup was 2 x 1Tb Samsung's in RAID 1 using the ISM RAID on a Gigabyte X48T-DQ8 motherboard. The tools that built the computer had installed Vista already even though I asked them not to... boo. But I got into the ISM setup at boot and had it create me a RAID 1 across the drive. This was cool...

Vista recognised it without the need for adding disks, drivers etc (as I expected to be honest). OS installed and all was well until we ran Ubuntu 8.04 from another drive. It came up as two drives...

"WHAT?", I asked. I quickly learnt there was such thing as "Fake RAID". Windows looked after fixing up the accidental change I had made to the drive in Ubuntu, but I really hated this idea.

Anyhoo... since then we have taken Vista off the "RAID" drives and instead used them for Media storage only. What annoys me the most now is every second or third boot for no apparent reason the ISM boot screen shows both drives as "Offline members".

"WTF?", I proclaimed. Nothing in the ISM menus really helped (options are Create or Delete RAID, wow!). This gets SILLY annoying because when the drives come back the Motherboard BIOS decides to set it as the main boot drive which of course fails.

So to you Intel Storage Matrix I say "GO AWAY". Going to see if the Gigabyte is more reliable. But I am disappointed first of all with the existence of this "fake RAID" business, my lack of prior research, but the fact that even then it seems so flakey.

Any one who ever reads this and has any ideas drop me a comment... but I have a feeling a firmware update or a drive format will help me. I shouldn't need that help though.

Monday, June 16, 2008

Welcome nobody

Hello nobody,

Nobody is going to read this (probably) except the people who I link it to. But hopefully one day a tid bit here can help somebody. I am going to try and keep this technical related. I am an Electrical Design Engineer in the Defence industry and run in to a whole range of weird things in the hardware and software world on a day to day basis.
I also dabble in some random things in my own time.

So this is my world:

Home time
What do I play with when I am home alone?
  • My machine is a Macbook from the very first generation with Mac OS 10.5 (+ a lovely Dell 24"er )
  • I code in Eclipse because its the same as what I use at work, and I love Java!
  • I am doing some coding under Vista including work with Media Center, Microsoft Speech SDK and the Media Player SDK. Mash all those things together and you'll work out what I am doing.
  • Occasionally I dabble in UAV related computer vision when I get the time, but that is pretty rare.
Work time
  • I do a bit of software work in a few different languages. I mainly code in C++, but regularly interface/work with Java, C#, Ada and Python.
  • I have played a bit with the Mono framework for C#, and interfacing that to C/C++.
  • Cross platform building plagues my (and Andrew's) poor little worlds. Day to day building (and coding) in Windows, Linux and QNX .
  • I use Eclipse for EVERYTHING at work. Every language (excluding any Matlab work) I have a plug-in for. Its a lovely central place to work and it means I only have to get to know one tool. The most efficient way for me to work is Eclipse for Windows, and I rely heavily on Samba to glue me to the *NX OS's.
  • Most of my electronics work revolves around data acquisition and control.
  • Embedded work I do usually revolves around the Microchip PIC's.
So thats me... and thats some of the stuff I might talk about. I wont really get into project specifics, but things that I run into that are interesting and worth talking about. The first two things I want to talk about are problems I have seen with my girlfriends Intel Storage Matrix RAID set up (on her new pretty freakin sweet PC), and also a little nuisance problem with GTK# and the Embedded Mono API. Boo.