Monthly Archive for March, 2009

Overlay UIView on MPMoviePlayerController

So you wanna overlay a UIView on MPMoviePlayerController?

Tried


[self.view addSubView:myView];

to no avail, right? The reason that fails is that MPMoviePlayerController actually creates a new window and overlays that on your app. This means you can’t just add a subview — it’ll just be hidden.

Try this oversimplified example:


MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:myURL]];

[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(playerFinishedPlaying:)
name:MPMoviePlayerPlaybackDidFinishNotification object:player];

[player play];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.text = @"Hi, I'm on your MPMoviePlayerController";
label.transform = CGAffineTransformMakeRotation(M_PI/2.0);
label.frame = CGRectMake(0,0,20,480);

[[[UIApplication sharedApplication] keyWindow] addSubview:label];

Wait, WTF? Clever folks might have tried [player _window], which works great on the simulator but fails to build for the device. The trick here is that the sharedApplication’s keyWindow IS the player’s window once the player is on screen, so adding a subview to that window overlays said view on the player. I did run into a bug where the keyWindow property was nil after the player was shown, so if you want to use that again later, make sure to call:


[self.view.window makeKeyAndVisible];

when the player calls back on your controller handling MPMoviePlayerPlaybackDidFinishNotification (in this case, playerFinishedPlaying:).

UPDATE: For iPhone 3.0, I can only get this to work with a bit of a hack — use a timer to show the overlay later. >.< Not sure I like this approach or think it’s reliable but it seems to work. Test it and YMMV for sure.


...

[player play];
[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(showOverlay:) userInfo:nil repeats:NO];
}

- (void)showOverlay:(NSTimer *)timer {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.text = @"Hi, I'm on your MPMoviePlayerController";
label.transform = CGAffineTransformMakeRotation(M_PI/2.0);
[label setBackgroundColor:[UIColor redColor]];
label.frame = CGRectMake(0,0,20,480);

NSArray *windows = [[UIApplication sharedApplication] windows];
UIWindow *mpw = [windows objectAtIndex:1];
[mpw addSubview:label];
}

mobicamp is coming to atlanta

mobicamp is coming. It’s my first event — go sign up! It’s going to be a blast.

iPhone 2.0 Proximity Sensor

Want to turn on the proximity sensor (shuts off the screen when something is close to the phone — e.g. phone is in pocket)?

[[UIApplication sharedApplication] setProximitySensingEnabled:YES];

Similarly, it’s pretty easy to shut it off:

[[UIApplication sharedApplication] setProximitySensingEnabled:NO];

That’s about all you can do with it, for now. I’m not sure if 3.0 will give the ability to read values from the sensor or not , which is what I really want. I need to dig into those docs.

Thoughts on iPhone 3.0

I watched a few liveblogs on iPhone 3.0 (namely gizmodo’s). I must say that I had high expectations going into the event, given the state of iPhone OS 2.0 (pretty good but not quite there).

iPhone has been one of my biggest thrills and disappointments at the same time. On the one hand, it ushered in a new era of innovation in mobile computing. No more crappy WinMo UI or Symbian UI. On the other, it lacked the simplest features that most Moto and SE flip/candybar phones feature:

  1. Bluetooth file xfer
  2. Blutooth tethering
  3. A2DP
  4. Almost anything else Bluetooth
  5. MMS

And it definitely lacked features that WinMo has had for years:

  1. API access to almost anything
  2. Multitasking (WinMo did it with 200MHz processors and crappy batteries so surely Apple can)
  3. Copy and paste!

Well, Apple fixed most of that today. They showed off a lot of new features in iPhone 3.0, many of which should have been there in version 1.1. I’m generally pleased by Apple’s announcements.

What’s coming in iPhone 3.0? Well, take a look at all of the stuff I wanted above — you’ll get most of it. Here’s the skinny — consumers get:

  1. Copy and paste!! (FINALLY!)
  2. A2DP (stereo bluetooth audio — wanted this for 2 years)
  3. Bluetooth tethering if AT&T allows it (I’m sure they will for a healthy $30 a month or some such fee)
  4. Spotlight – search for stuff in Apple apps or use it as a launcher to find apps
  5. MMS
  6. CalDav calendar support (also a must for me!)
  7. Notes sync

There’s more, but that’s all the cool stuff. Did Apple forget the devs? Nope. We get a lot of cool new toys too, some of which would have been nice a month ago when return7 started work on its next app (currently in beta):

  1. Proximity sensor API (yay! we can be hot shots like google now and boy do I have a kick ass app idea using this)
  2. Peer-to-peer discovery/ip connection ala bluetooth+bonjour (it’s 1-to-1, not n-n)
  3. Accessories can access the dock connector or hit the phone via bluetooth — can dream up so many cool robots w/ this now
  4. Google maps API (can’t be used for turn-by-turn)
  5. Official blessing for turn-by-turn (Garmin, give us some love..please!)  but bring your own maps
  6. PUSH NOTIFICATIONS! Hi, welcome to not September 2008. Better late than never, though. I must say, I prefer either backgrounding or some runner that calls some standalone script in an app that’s limited to 10 seconds or so of execution time…but this’ll do. :)
  7. VOIP Service of some sort for apps (not sure how this’ll work but here come the 10 million walkie-talkie apps..they’ll be the new ToDo app)
  8. Access to the music library on the phone
  9. Easier audio recording
  10. Upsell on paid apps (basically makes it easy to do things like episodic content for users)

Once again, there’s more, but those are the highlights. Did I get all of the answers I wanted or everything I wanted? No. Did I expect to? Not so much. I think Apple’s done a pretty good job of appeasing the fanboi (and the !fanboi) in me, though. Will be excited when/if they announce a new iPhone later this year.

Edit: give me tethering.

Top 10 Freeware Apps for OS X (Leopard)

Another Top 10 freeware apps list? Gasp! Why should you download all of the apps on my list? Because my list is the best and that’s how I roll. These apps are in most-useful/descending order. They’re ranked on the entirely subjective (and somewhat arbitrary) amdev scale (max of 5). Just the fact that these apps are on this list warrants high ratings.

1. Adium – Yes. I went there, iChat fans. Unified contact list (without hacks)? Check. Merge contacts into a single cell? Check. Skinable? Check. Cute little duck mascot? Double check. Adium makes chat a breeze and it doesn’t crash. It supports all the popular stuff plus facebook, which you may or may not want to use. Adium gets 5 amdevs.

2. QuickSilver – This is a super useful launcher. I use it tens of times per day and it saves tons of time finding/opening apps. You can do tons of advanced things like select files, hit a couple of keys, and attach them to an email to a given contact in about 3 seconds. Love it. 4.9 amdevs.

3. Cyberduck – Cyberduck freaking rocks. It’s the BEST freeware FTP/SFTP/WebDav/S3 client on the market. It gives my personal fav (Panic Software’s Transmit) a good run for its money. I used Cyberduck for a long time before switching and I could have kept on using it without problems, but I <3 Transmit. 4.8 amdevs.

4. Fluid – Fluid is this neat app that lets you turn webapps into stand-alone apps. Why’s this useful? Ever had Safari crash while you were typing an email because of some blog w/ 8 bajillion flash banner ads? Yes? Get fuild. 4.7 amdevs.

5. VLC – Hey, I’m trying to watch this video I downloaded and I couldn’t because I was missing a codec or perhaps it was in some obscure wrapper. VLC plays damned near any kind of video on the interweb. 4.4 amdevs because the video can look washed out before you adjust it, relative to something on that “other” platform.

6. uTorrent – Finally, the best torrent client for Windows is now on the Mac. 4.3 amdevs because it’s not 100% as good as its Windows counterpart yet.

7. Skitch – Skitch is a cool way to take screenshots. It’s a unicorn that makes command + shift + 4 look like a pony. 4.0 amdevs.

8. Jing – Jing lets one make screencasts for free (there’s a paid option too if you need more flexibility). 3.9 amdevs because the free version doesn’t let one do anything but a proprietary swf.

9. Flip4Mac – Flip4Mac for all of the people who need to play back Windows media without booting up a VM or using bootcamp. It’s been around a while and the free version is playback only — good enough for me. 3.8 amdevs.

10. Burn – Let’s face it, most of us don’t burn many discs anymore. There are better ways of moving data (the internet and external/non-optical storage), but every so often, one needs to burn some MP3s or some other odd and end. Burn is the lightest and simplest burning software I’ve found for Leopard and simply put, it rocks. Grab this. 3.6 amdevs.

There you have it. Ten free, rock-star apps. What are your favorites?