A few years ago, I got a Roku Soundbridge for my birthday. It’s a pretty awesome, media streaming device that works with a variety of media streaming servers, including Windows Media Connect, which integrates nicely with Windows Media Player that I use to manage my music. (pro-tip: installing Windows Media Player 11 on Windows Server 2003 is not fun).
Anyway, one of the nifty things about the Soundbridge is that it comes with a simple Remote Control Protocol, so apps on PCs and phones can connect to it and control it remotely. Shortly after I got the Soundbridge, I wrote a simple app to turn it on, connect to my media server and play some random music to wake me up in the morning. Although this was working all fine and dandy, there were two problems with it: it was written in VB.NET 1.1, so any changes would require cracking out Visual Studio 2003, or upgrading it, and it would be so much nicer in some sort of script so that I wouldn’t have to keep recompiling it to change it. Unfortunately socket-based communications tend not to be the strong point of most scripting languages, so VB.NET was the best thing to write it in at the time.
Then along came Powershell. The great thing about Powershell is that it can access any .NET Framework assembly, type or member, so if one could knock up a handy library to simplify interactions with the Soundbridge, Powershell could be used to run off the appropriate commands.
So that’s what I did. I now have a library that exposes a public SoundbridgeClient type with some public methods for the RCP commands and a Powershell script that does the checking and runs everything in the correct order. I hope to post the library and script on pixa.org.uk soon. It’s not very powershell-ish though – it’s all .net objects and methods, no nice fancy pants cmdlets yet – but I like that it will make maintaining the script quicker and easier.
0 comments:
Post a Comment