Tuesday, October 21, 2008

Some bugs fixed...

I finally took some time to fix some longstanding issues with ooTunes.  The biggest one is that now you can tell ooTunes to use a local address when you're on the same network as your ooTunes server... which is a) much faster and b) should work with routers that are dumb and can't connect to a local computer using a remote address).  It's off by default but if ooTunes detects that your router isn't working with local addresses, it's turned on automatically.  You can manually turn it on/off on the "remote access" preference page.  There are also some optimizations to speed up logging in, and more info about your current ip (both local and remote) on the "remote access" preference page.  If nothing else  I hope it will prevent lots of support emails asking "why can I connect from my iPhone, but not locally"? 

Create Genius Playlists in iTunes on the go using ooTunes ... thank you Applescript

I've been taking a break from the pain of getting a firewall-avoiding/live-video-playing ooTunes iPhone app finished to spend some time on the ooTunes Media Server.  I've fixed a number of longstanding bugs and added a few new features.

One major new feature is that (as promised) I've finally added Genius Playlist creation to ooTunes!  What this means is that when you're listening to a song on random in ooTunes, and you decide that you want to make a Genius playlist from it, it's as easy as dragging that track to the "Genius" playlist.  Well, I say it's "that easy", but that's not exactly correct (and it wasn't trivial to get working):

Caveat Emptor -- or six
  1. This is currently only working in a regular browser (not on the iPhone yet).
  2. This only works on Mac's (sorry PC, you've had a rough couple of years, I know).
  3. This only works on Mac's when you turn on "User interface scripting" also known as "Support for Assistive Devices"... 
  4. It requires iTunes to be brought to the front and may even have message boxes popup in iTunes on your ooTunes server computer.
  5. It may not work on non-english versions of iTunes. 
  6. You have to already have the track in your iTunes library, and "Genius" has to be updated since that track was added.

So why all the caveats?
1. Because I haven't come up with a clean way to do drag/drop on the iPhone like I can in a regular browser
2. I have to use AppleScript to create the Genius Playlist in iTunes, there's no equivalent commands for the windows COM interface to iTunes.
3 and 4. There is no menu command or shortcut key or AppleScript Library entry in iTunes to allow access to the "Start Genius" feature of iTunes... it's almost like... oh, I don't know... Apple DOESN'T WANT YOU TO BE ABLE TO DO THIS?!?... so it's fragile (could stop working with the next version of iTunes) and annoying (the Applescript has to simulate clicking a mouse on the button, which means iTunes has to be at the front, and a message box may appear if the track can't be used to create a Genius playlist).  
5. The button can't be found by anything but name so it's not going to work for other languages unless "Start Genius" is never translated to your language in iTunes.
6. Unfortunately, you can't create a genius playlist from any old song... I was hoping to make it so you could find music you DO own that's similar to music you DON'T own (ie, from pandora, last.fm, seeqpod, radio, etc.)  But you simply can't.  You must have the track in your iTunes library already, and you have to do the "Update Genius" after adding any new tracks, if you want them to work with the Genius Playlists.

So, there you go, I've made good on my promise, now try it out (although you can't in the demo cause I don't have enough legal tracks there for iTunes to make any suggestions... sorry!)

So there you have it, it'll only get better (hopefully).

Oh, and so no-one has to reinvent the wheel, here's a download of the applescript ooTunes uses (more or less).  Feel free to do what you like with it but, but please leave the comments in there and the copyright notice with the link to this post! 


(*

(C) Steven Woolley 2008, as part of ooTunes Media Server (see ootunes.com)

  

How to create an Genius Playlist in iTunes using applescript.  More info and issues discussed here:

http://ootunes.blogspot.com/2008/10/create-genius-playlists-in-itunes-on-go.html 

Feel free to use this code however you'd like, but please keep this comment intact so I hear feedback, etc., since I'd like to hear about updates, improvements, suggestions, etc. 

*)


set pid to "4B62C662B53FFB94" -- set this to your track's persistent id... or use some other method to get your "seed" track


set app_name to "iTunes"

tell application "iTunes"

try

with timeout of 10 seconds -- don't want to hang forever if, for instance, iTunes has a dialog box already open

set cur_track to (first track of playlist named "Music" whose persistent ID is pid)

reveal cur_track

end timeout

on error theError

return "Can't find track!"

end try

end tell


tell application "System Events"

tell process app_name -- this needs Assistive Devices support enabled see: System Preferences -> Universal Access -> "Enable access for assistive devices"

try

set b to first button of window app_name whose help is "Start Genius." -- that's about the only way to get the "Start Genius" button, but it will break on non-english versions (I'm guessing)

tell application "iTunes"

activate

end tell

click b

with timeout of 1 second -- this is a hack to "test" if the "can't create genius playlist..." dialog opened.  If it does, we'll timeout (hopefully) and then close the dialog so it doesn't freeze future applescript interaction

tell application "iTunes"

activate

end tell

end timeout

return ""

on error theError

if theError is "iTunes got an error: AppleEvent timed out." then

key code 36 -- close the dialog 

return "Can't create genius list from that track!"

end if

return theError

end try

end tell

return "Error creating genius playlist!"

end tell

Friday, October 10, 2008

Why you can not play live video on the iPhone

The question I and many others have about the iPhone is: 

Can we make it play live video?  

I'm not talking about prerecorded video (that's doable, and really easy, ooTunes does that already, along with tons of other apps, including the youtube app).  Also, I'm talking about this in the context of an officially released app in the app store, built using the iPhone SDK.  The problem has already been solved using the jailbreak toolchain, but doesn't work for official apps because of 3 and 5 below, and 4 below is still very applicable. 

I'd be ecstatic if someone would prove me wrong on any of this... so put in your comments, please!

So, nothing's impossible, but it's extraordinarily difficult for the following reasons:

  1. There is nothing built in to the iPhone to handle true rtsp streaming
  2. The only formats available to be played on the built in video player are .mov, x264 or mpeg4 all of which require a frame index in the moov atom at the beginning in order to be played as they're downloaded.  Unfortunately, for a live stream such information is simply not available until the encoding is finished.
  3. Should you desire to build your own video player, the SDK doesn't give access to the private frameworks that apple uses for video decoding or the raw framebuffer that a player would need to have fast display.  There are workarounds (that are suboptimal) but no one can show source thanks to the developer NDA that is still in effect. (technically this comment is probably out of line, though I've gleaned it from reading/searching the web, NOT from the sdk). 
  4. Without proper hardware optimized methods, you're going to be a battery hog, and probably limited in resolution.
  5. Now, imagining that all of the above is somehow overcome (which I am sure it has been by some)... now the question is: "Will apple accept your app into the store?"  It is against the terms of most (if not all) service provider's agreements to stream live anything (and video isn't going to be low bandwidth).

So, the options are:
  • Figure out a way to encode live video with predictable metadata (fixed frame boundaries and packet sizes)
  • Write your own video player from scratch to decode whatever type of stream you want (remember 3, 4 and 5 above)
  • File feature enhancements and otherwise petition Apple in hopes that they'll add support for RTSP or change their SDK to allow for this.
  • Encode in short snippets and try to play them back to back seamlessly, with no breaks... this way you almost have live video (delayed by the amount of time to encode and start playing a single snippet).
  • Give up on it?

So for ooTunes, I've learned the hard way all of the above.  My latest efforts have been in porting the ogg theora video codec.  I've gotten as far as decoding, but can't yet display fast enough due to 3 and 4 above.  It's questionable due to 5 whether it's even worth anyone's efforts.

Hope that helps someone, and I also hope that someone can prove me wrong on some of the negative stuff above. 

Wednesday, October 1, 2008

Woohoo! Apple finally drops NDA on iPhone development!

See mac rumors note here:
Apple Drops iPhone Non Disclosure Agreement (NDA)

This is a wonderful thing for ooTunes!  I'm about halfway to getting video working (live video that is) but one of the libraries needed didn't have source available due to the NDA.  Now I don't have to reinvent the wheel!  Example code will be much more available, etc.  now if only I had 26 hours a day!  

Had to say something... after the meanish stuff I've said in the past.

Thursday, September 18, 2008

hallelujah!

I finally finished going through my latest list of radio stations from the ooTunes demo to mark them as working or not!  This resulted in about 2897 stations confirmed to be working with the iphone (and this is by no means a complete list of stations that will work).  This is good for at least 3 reasons:

  1. It forced me to finally get Real Audio streams to work
  2. It made me realize I really need a way to add streams directly from ooTunes (it's about half implemented already)
  3. I can FINALLY get back to listening to my own music and streams (instead of having to listen to conservative talk shows, sports shows, religious shows, and boring political news)
So, coming soon:  search and add stations from the your iPhone/browser, lots more radio stations (including BBC stations that didn't work before due to using Real Audio), Genius Playlist creation (even from songs you don't yet own, but like, ie, from seeqpod), and some bug fixes.

App Store humor

decision tree for apple accepting new apps to the app store
Enjoy!

Tuesday, September 9, 2008

Are Genius playlists the beginning of the end for last.fm and Pandora?

Good news for music lovers ... bad news for last.fm, pandora and the like...


iTunes' new Genius playlists are, well, genius!  With one of the most installed and (more importantly) most used music players apple would be foolish to NOT get users' play data and 

 

  1. use it to make their offerings better and
  2. use it to PROFIT!


So my initial impressions:



It is a bit scary signing up... anonymous, but... um, yeah, give us your iTunes Store account name and password... but it's anonymous, we promise!  Did we mention how anonymous it is?  Well it is totally anonymous!  


I'm not a "privacy" nut.  I recycled my tinfoil hat for some quick cash.  If I was, I wouldn't be blogging, or scrobbing with last.fm, etc.  I understand why they need the "privacy policy" and your account info (in fact, I actually read the privacy policy associated with enabling Genius in its entirety... it's actually short and sweet).  It's not a super big deal, and I applaud apple's upfrontness about it.


Okay, one hurdle down.  Next iTunes spent an hour or more reading my library and playcounts, dates, ratings, etc (it was probably closer to an hour and a half, but I have something like 14,000 tracks so your ymmv).  Then, after telling me it had been submitted, I was informed that Apple was

 processing the data.  A few minutes later:  Success!  


"You can start pestering the Genius!"  <-- this is NOT what it said, I forgot...


So, I tried it out, and it did a pretty good job, at least on the first few attempts, at least with the non-obscure stuff.


Biggest rightside downside?  

The Giant Genius sidebar... of course.  If you're like me, you may just want to hide that Genius sidebar right off the bat.    I refuse to buy tracks from the iTunes library before looking around to see if I can buy the real physical cd online for less.  I like tangibles, and don't mind the wait for delivery and ripping, but I'm probably in the minority there, given the success of the iTunes music store and certain less legitimate

 means...  Of course the sidebar might be good for recommendations even if you don't buy from iTunes, so I'll look into it eventually I'm sure.


(NOTE, I do applaud that it recognized probably the only major Johnny Cash album that I don't (yet) own, and didn't try to re-sell me all the stuff I already bought... that is smart use of info... something that last.fm and pandora really CAN'T do, at least not very well).


So, is this really the end for last.fm and pandora?  Not really... Until Apple/iTunes will let you actually play stuff (more than 30 seconds) from songs you don't yet own, they can't compete with the music discovery aspect of those guys... but if I were an investor in last.fm/pandora, I'd be a bit scared (given the licensing costs we've heard about...) and now this encroaching by Apple.  But, oh well, I'm pleased with apple's move, and competition is a good thing, right? Right?


And the best part of it all?  ooTunes didn't break with the update to iTunes 8.0!  In fact, genius playlists just show right up (both in a regular browser or in the iPhone).  The only problem is that it doesn't use a neat new icon for Genius lists (kinda gonna be hard to come up with an icon more genius than nerdlinger,  

but I guess we can give him a pocket protector or einstein hair or something.  Look for an update soon that fixes that minor issue, and HOPEFULLY a way to create a genius list on the fly, through ooTunes, using not only iTunes tracks, but maybe even pandora, last.fm, seeqpod, or other tracks (no promises on this, but if it's possible, I'll do it!).