Cocoaphony

87

Huge changes in PandoraBoy on the way. I’m working on full-screen mode, so you can run PandoraBoy from across the room and still see what’s currently playing. Building a smooth transition from window to full-screen without interrupting playback has taken my a couple of days, but I think it’s a pleasing effect. Right now it doesn’t do a lot more than be a full-screen Pandora window (which isn’t very exciting in itself, though much harder than it sounds), but next I’ll work on a plug-in architecture to let you put various information on the bottom portion of the screen. Then it’ll actually be useful.

Why is it so hard to go full-screen you may ask? Afterall, it’s just a webpage. But the mini-player is a web page that assumes the window is a specific size. Getting the background gradient to look right at any size is the main problem, since there is no direct way to scale a background in CSS2. repeat-x handles left-to-right scaling, but the pandora background isn’t tileable vertically. My final solution was to build an NSImageView which holds a flipped version of the Pandora background, and then placed it immediately underneath the pandora webview. It handles all vertical stretching and gives a nice darker area at the bottom rather than just fading to white.

I’ll also investigate a black-screen mode with the pandora player standing with no background. I had that working at one point, but it’s been hard to recreate it in a way to zooms cleanly. CSS2 and Javascript just aren’t nearly as powerful as Cocoa….

If you’re feeling insanely adventurous, it’s all checked in on truck in subversion….

86

PandoraBoy 0.5 is live. Go forth.

I may not get to work on PB for a few days at least. One-way call paths will be my life for a little while I suspect. Or maybe it’s just USB audio input failing in some strange way… ah telephony.

85

PB 0.5 is in my final testing. Just going to let it run a few hours before I post it on Monday. Adds station changing (finally) from menu, applescript or hotkeys. It’s actually a much larger change than it looks. There was a lot of under-the-covers restructuring while I got that working.

Next plans: either investigate how to masquerade as iTunes (so that stuff that works with iTunes will transparently work with PandoraBoy), or work on some eye-candy features (full-screen mode, floating semi-transparent windows, etc.)

83

Why is it when I want to test PandoraBoy with an album that has no artwork available, suddenly Pandora becomes so good at having every piece of artwork on every track for 7 different stations until I run out of hourly skips?

Well, at least I finally fixed that stupid “thumbs-up in the lower left of the Pandora window” bug that’s been driving me crazy for so long. Check for nil returns people!

I’m still trying to understand how Pandora manages skip tracking. I’m not planning on circumventing it, I just want to mark skipped tracks in the track listing (Cmd-T). Skips don’t seem to generate traffic back to the server or unique API events, so it seems that the client keeps track of skip counts. But it also seems persistent across Pandora restart, so I guess they’re storing it in Flash local storage. I swear they didn’t used to keep track of skips if you switched stations and then switched back, but then they also didn’t used to keep track of your place in the song when you switched stations. Curiouser and curiouser.

81

I’m switching jobs over this weekend from information security to Mac development. In the process, I’m also moving mostly to work-from-home, taking over a corner of my wife’s workrooms and turning it into a decent home office/lab. In the process of copying huge files around, I think I pushed my Linksys over the edge and it stopped talking on its WAN (PPPoE) port. In my researching trying to fix it, I learned that the Westell modems that Bellsouth gives you for FastAccess are in fact full routers. And actually I’d say it’s a bit nicer router than the Linksys. So project #3 in the the “get ready for new job” turned out to be “completely reorganize home network.” I like the new setup, though. I can get to the Westell directly now (192.168.1.254) for diagnostics. And the Westell has a nice NAT setup system.

On the annoying front, for some reason my Microsoft Laser Mouse 6000 which has worked so well for me for so long at the office, now doesn’t reliably click. Moving it works fine, it just doesn’t always recognize clicking. It’s driving me nuts. I’m wondering what the change is. I’m on Leopard now, which might impact it. Just not certain.

Moving over to Leopard on my primary box also meant spending a lot of time trying to get PandoraBoy happy. I’ve been having trouble with the Shortcut Recorder palette for a long time now where IB won’t load the palette. I think I’ve finally gotten it sane again. Definitely staying on Xcode 2.5 for now. I’ll wait for SR to get their Leopard IB3 support solid before I consider moving. I’ve had requests to get PB running on 10.3.9, and I’m not ready to try that in XCode3.

Oh, and first impressions of moving to Leopard: wow, Leopard rocks.

79

Have I mentioned recently how much I love Cocoa? Even when I hate Cocoa, I love working in it. And things that drive me nuts (like the lack of regexes) come along in due course (Leopard). I was listening to CocoaRadio today and there was a comment along these lines. Cocoa has been evolving for about 20 years now. Much of the core is carried over from NeXT. But rather than “showing its age” it keeps showing its wisdom, and those early guys thought it out well enough that Apple hasn’t had to start over again and again as Windows has with Win32 to MFC/WTL to .NET. For how unusual Objective-C is, it’s a constant rather than moving between C, C++, C#, and Java as the winds blow. (And the more I program in Objective-C, the more I enjoy it.)

Tonight I added a station-changing menu to PandoraBoy. There’s still a lot to add to make it really useful (hotkey support and Applescript at least), but the core’s there, and it wasn’t hard. It forced me to simplify a slight duplication in the object model (PandoraControl and Controller were doing almost exactly the same work so I’ve merged them). That cleaned up a lot of redundant code. Even after merging the two objects, Controller is under 400 lines of code, so I don’t think I need to worry about splitting Controller back up some other way.

77

More hacking on station lists tonight. So far it’s been as easy as I hoped, once I created a reliable way to watch all Pandora traffic (through NSURLProtocols). The station list comes back as an XML document, and I can copy that off into an easy array for later use. The only thing I need to work more on is QuickMix management, since those are magically pulled out of the main channel list, and I should probably do the same to avoid confusion.

I’ve talked often with folks about XML and how there are so many good ways to compress it quite effectively and it’s strange that XML developers have chosen not to do that. Rather, real XML winds up being insanely verbose and bloated on the wire. I hereby take back my earlier complaints. The fact that I can read XML by sniffing the traffic without having to apply any decoding (not even gunzip), and can recognize XML easily when I come across it, is one of the biggest boons to reverse engineering I’ve ever encountered. Long live human readable data formats!

75

I knew I’d run into this when I released PandoraBoy 0.4.0, and someone ran into Issue 17. Moving from MacOS 10.4.10 to 10.4.11 included a massive change to WebKit, and the 0.4 line was meant to address this. Unfortunately I no longer had a 10.4.10 box to test against, and so I figured that something would probably break. Hope against hope, I figured everyone would have upgraded by now.

Anyway, I will now undertake a series of “did this fix it” patches and we’ll see if we can get it working again. Hopefully the entire problem was my removal of decidePolicyForNewWindowAction: which never seems to be called in the new WebKit under Pandora (but I should have kept for completeness anyway). But it’s possible that the problem is deeper.

73

It’s been quite a while since I’ve updated the Rob Report, but I have some things to chat about on the technical front. Most of my work these days is on the Mac, and my main hobby project is PandoraBoy, which will probably dominate these blog posts for a while. It’s been a great project for teaching me how to deal with some interesting parts of Cocoa, while being small enough to keep my brain around.

My current project for PandoraBoy is getting control of station changing. I now have a set of proxy NSURLProtocols that I can use to eavesdrop on the Pandora traffic (rather than having to post requests like listStations twice). That’s how I grab album art. I’m using it to learn much more about how Pandora talks to its server, allowing me to provide more Mac-friendly ways to send those messages. I’ve demonstrated now that I can send launchStationFromId messages from Cocoa, so now I just need to collect the results of listStations so I have the IDs to send. Shouldn’t be hard now.

In the process, I discovered FireBug, which is just incredible. Using it, I understand Pandora’s code much better and am now mulling about what I could do with all this information. But my next project will probably be talking to Airport Express (after I fix a couple of new bugs in the 0.4 line). I’m pretty close to calling this thing 1.0….