Saturday, May 22, 2004


Quite a long one. Sorry about that.

Got my remote control for Windows Media Player working. It's put together like this:

  • Shared Class (inherited from MarshalByRefObject) that essentially just contains a Media Player object (using the Primary Interop Assemblies from Microsoft)

  • Remoting server app (just a console app that registers a remoting service exposing the class created above via a tcp channel)

  • Mobile Web page (just a .aspx page) with 2 forms

The forms at the moment are pretty basic. There's a main form with the currently selected Album and Artist displayed, along with buttons for next track, previous track, stop and select new album. The second form lists all the albums in my media library, and allows you to select one to play before taking you back to the main form.

It's far from perfect. I need to have a further look through the docs for mobile web forms - there doesn't seem to be a mobile equivalent for a LinkButton. I suspect, although I've got no way of checking, that when it's actually rendered on a WAP phone all the commands are rendered as plain text, like menu options. Just browsing to it in IE, however, makes it look pretty ugly. I've either got a big stack of buttons, or a funny menu thing which takes you to a page with further details of the album object. That's why I need to look into the list controls etc. Although having said that, it might be kinda useful. I'll have to see how it looks on a real phone.

The remoting class returns the album list as an array of AlbumDetails (AlbumDetails is implemented as a small class with just 2 properties, Name and Artist). This array is then put into an ObjectList. This was the only way I could find of producing a list of albums which could be used to send a command back to the server.

I guess I could just sling them all in as links, posting the page back to itself and adding a parameter to the URL. It's worth a look. I might just end up doing it that way. Who knows.

I think I might also have a look at adding a volume control to the page. It'll only be 2 buttons, one for up, and one for down. Don't think it'll be terribly tricky to do. Just add the volume changy function to the remotable class and hey presto! Volume adjustment ahoy.

I might also develop the remoting server into a proper Windows Service. Shouldn't take too much work, and it'll look more impressive (to me, anyway...) not having to start a console app to make the web page work.

Other than that, there's just a few polishing bits to do. I'd like to develop a bit more error handling in there. At the moment it's a bit fragile. I've been seeing plenty of those nice buff-and-red pages pop up if I haven't done something right.

I need to have a look at array comparison stuff as well. WMP doesn't have a built-in function for getting a list of all the albums in the media library, so I've got an iterator going through every track and putting the album name into an array. If the name's not already in there it's added. If not, then it goes onto the next one. However, the comparison's case-sensitive, so there are a few duplicate entries in the list. I can either clean up my media library, or clean up the code. I know which one's going to be more interesting!

It's still a tad limited. Since I haven't got full-blown VS, I haven't got native .NET CF support, but I'm sure I'll be able to find some sort of workaround. If I do, then I can build something with a bit of a richer interface and a bit more interaction. Until then, I'm just happy to get it working over WAP. My first foray into the wonderful world of remoting objects and mobile computing.

I love this book.

Once again. Sorry about the length.

No comments: