Posts filed under 'Songbird'




4 singing birds

At the OpenSolaris Developer Summit this past weekend, I had the chance to present Songbird. We thought it would be cool to basically do a group talk, so I enlisted the help of Albert Lee, Alfred Peng, and Ken Mays (all members of both the OpenSolaris community and the Songbird community) and the four of us gave a talk & demo.

(with many thanks to Jim Grisanzio for his excellent photo-taking skills and camera)

Add comment May 5th, 2008

Reading gzip compressed data via Javascript

This weekend while I was working on my Magnatune extension for Songbird, I found I needed to fetch, expand, and parse a remote gzip’d XML document. The fetch was easy (XMLHttpRequest), as was the parse (DOMParser), but I had no idea how to do the expand.

Fortunately, Mossop over on extdev pointed me at Mozilla’s streamConverter services.

Unfortunately there wasn’t much sample code for me to blatantly rip-off^W^W^Wlearn from, so after much bumbling around like the JS amateur that I am, I finally got something working. I’m documenting it here so that hopefully others might find it useful. Or at the very least, I can look it up again when I will inevitably need to do this again :-)

Mossop first pointed out that I wouldn’t be able to use XMLHttpRequest and that I would need to open a channel:

// Get the IO service
var ioService = Cc["@mozilla.org/network/io-service;1"]
        .getService(Ci.nsIIOService);
// Create an nsIURI
var mtUri = ioService.newURI(magnatuneURL, null, null);
// Create a channel from that URI
var chan = ioService.newChannelFromURI(mtUri);

Awesome. The tricky part now is the docs lie. They say there is a gzip to uncompressed stream converter that implements asyncConvertData() and a synchronous convert(). I opt’d for synchronous since it seemed easier to get working off the bat, but kept getting error messages saying it wasn’t implemented. Turns out that’s true. The gzip->uncompressed method only implements asyncConvertData. So now I’d need to define a stream listener (implementing the nsiStreamListener) interface. This is the listener that is invoked for each uncompressed chunk. It needs to implement onStartRequest, onStopRequest, & onDataAvailable where onDataAvailable is passed the uncompressed data:

function StreamListener() {
    this._data = null;
    this._first = true;
}   

StreamListener.prototype = {
    onStartRequest: function(aReq, aContext) {},
    onStopRequest: function(aReq, aContext, aStatusCode) {
        // this._data is my full uncompressed file now, for Magnatune this is my
        // XML file, so now I can go do whatever I want with it.
        Magnatune.Controller.completeSyncWithStore(this._data);
    },  
    onDataAvailable: function(aReq, aContext, aInputStream, aOffset, aCount) {
        var binInputStream = Cc["@mozilla.org/binaryinputstream;1"]
                    .createInstance(Ci.nsIBinaryInputStream);
        binInputStream.setInputStream(aInputStream);
        if (this._first) {
            this._data = binInputStream.readBytes(binInputStream.available());
            this._first = false;
        } else
            this._data += binInputStream.readBytes(binInputStream.available());
        binInputStream.close();
    }
};

So now that I have my channel open, and my stream listener defined - I need to create my nsIStreamConverter service to take the gzip’d data from the channel, and pass it to the stream listener so it can do its thing with the uncompressed data.

// Get the converter service
var converterService = Cc["@mozilla.org/streamConverters;1"]
            .getService(Ci.nsIStreamConverterService);
        
// Instantiate our gzip decompresser converter
var converter = converterService.asyncConvertData("gzip",
            "uncompressed", myListener, null);

So now that we have all our pieces defined, all that’s left to do is pass the converter to the channel and start the pipeline:

// Initiate the asynchronous open.  This will initiate the connection
// to Magnatune, grab the gzip'd data and pass it to our gzip converter
// which will then call the StreamListener, so our completion hook is
// fired in the StreamListener's onStopRequest()
chan.asyncOpen(converter, null);

Awesome. So now every Songbird/Magnatune user will be downloading a 300kb gzip’d file instead of a massive 6MB file each time they sync with the Magnatune DB.

10 comments May 5th, 2008

magnatune mostly complete

worked some more on the magnatune store interface for Songbird. got the following up:

it’s neat. you can browse the 7600+ tracks available at magnatune and play the full length of the song exactly as if it were a local library. right now clicking the “buy this track” button pops up a new browser tab and takes you to the page to enter your info to purchase the MP3 (without the magnatune nag voice at the end of each track that you hear when you play directly from the store)

they have an API for doing purchases directly, but it involves transmitting a credit card number via a URL. ick. i need to test to see if it accepts those variables via POST instead of GET to make it a little more secure. if that works, then this would be pretty neat. if i can get a better integrated purchase experience, then i’ll consider this complete.

update: uploaded the add-on here

1 comment May 1st, 2008

magnatune for the bird

I first heard of Magnatune at LUG Radio Live where they had a booth setup. I didn’t get a chance to check them out until yesterday, and it’s a pretty cool site. There’s some neat electronica up there along with the other usual genres. Their business model looks pretty interesting too, along with their CC friendliness and promotion of music sharing.

I started mucking about with a Songbird add-on last night and got something working a few hours ago that builds an additional “Magnatune” library in Songbird to represent all the tracks available on Magnatune. You can play them directly from the remote track (yay open web!) currently. I plan to add a way to purchase the track so it can be added to the local library as well (which should also allow it to be sync’d after purchase then too). It’s been an interesting challenge… and I’m still running into a few hiccups, I suspect because of the way I now effectively have two local libraries (which shouldn’t be that big a deal since devices, etc. all have their own libraries from Songbird’s perspective).

Anyway, it’s been a fun project so far… and I have to say, there’s something cool about having all 7600+ Magnatune tracks available for direct play within Songbird. I’ll definitely post this to the addons site when I’m done.

4 comments April 30th, 2008

OMFG!!! jamendo songbird integration!

omfg, why didn’t anyone tell me Jamendo started doing Songbird integration!?!?!?! i’ve been getting my music via Firefox this whole time.

many thanks to Mike Linksvayer over at Creative Commons for pointing out to me that Jamendo kicks some serious ass in Songbird.

go check out pornophonique’s 8-bit lagerfeur album. it’s wicked 8-bit gameboy-style rock. my favourite track is “sad robot” (the first track)

1 comment April 28th, 2008

Naming nits

It’s Songbird, not SongBird.

It’s OpenSolaris, not Open Solaris.

(yeah yeah, I realise I’m hardly qualified to be the grammar nazi, but those two do bug me)

5 comments April 22nd, 2008

ghostbusters!

Yeah yeah, I’m a movie-themed Media Views kick apparently…

I threw together a derivative of yesterday’s Attack of the Clones Media View, this time titled Ghostbusters

Ghostbusters!

This one views all the broken tracks in your library, e.g. those tracks who have been deleted from the filesystem or renamed and are no longer valid entries.

Add comment April 18th, 2008

attack of the clones!

half the fun of making an add-on is coming up with the name… so here’s my newest:

Attack of the Clones!

i got tired of replying to all the Songbird posts asking for the ability to remove library duplicates with “it’d be a simple add-on to write”. i finally decided to write it. i also wanted to play with our new media views feature, so i implemented this as media view.

once you’ve installed this in Songbird, go to your library and then click on the Media Views button (button the right of the search toolbar) and select “Attack of the Clones!”. the media items it will show you are all the duplicates in your library. you can select individual ones and the XUL label above the playlist widget will show the full path. simply find the ones you want to remove and right-click to remove them (from the library… i don’t remove from the filesystem)

update: duh. whoops, forgot to actually link to the damn thing. here it is! thanks mark!

3 comments April 17th, 2008

french celtic rock?

bizarrely intriguing.

i came across Bézèd’h’s Ton jour viendra album clicking through Jamendo yesterday and have found it pretty catchy.

the french celtic rock sound is definitely unique. and hey, it’s creative commons licensed with 192kbps MP3 and Ogg Vorbis torrents available. now this is what we’re always harping about as the Open Media Web.

rockin’.

i sent $10 their way. the best part?

Donation to the artist Bézèd'h       9.50 USD
Promotion on Jamendo.com    0.44 USD
Tax     0.06 USD
Total with taxes    10 USD

how awesome is that? Bézèd’h gets $9.50! that shit ain’t happening on iTunes, i can tell you that much.

3 comments April 16th, 2008

yay history meme!

originally from planet gnome but it looks like the meme jumped worlds over to planet mozilla where i found it from dan mills (of weave fame).

wonder if it’ll jump worlds over to planet opensolaris too.. ?

[stevel@grommit:~] 501$ uname -a
SunOS grommit 5.11 snv_75 i86pc i386 i86pc
[stevel@grommit:~] 502$ history | awk ‘{a[$2]++ } END{for(i in a){print a[i] ” ” i}}’|sort -rn|head
87 ls
81 cd
41 vim
38 ll
22 cat
18 svcs
14 java
12 svcadm
11 su
10 ps

1 comment April 14th, 2008

Previous Posts Next Posts

Search

Pages


New Photos

2008-07-24 OSCON Day 1 by Stephen Lau2008-07-23 OSCON Day 0 by Stephen Lau
2008-07-21 Bummin' Around Portland by Stephen Lau2008 Photos of Char-siu by Koshi by Stephen Lau
2008-07-05 Climbing Six Toe Rock at Castle Crags by Stephen Lau2008-06-28 Neighbourhood Beagles by Stephen Lau
2008-06-28 Sailing the SF Bay by Stephen Lau2008-06-27 Wendy's Residency Graduation by Stephen Lau
2008-06-16 Wendy's Graduation by Stephen Lau2008-06-21 Cathedral Peak w/ Jaime & Zac by Stephen Lau

Categories

Links

Meta

Calendar

July 2008
M T W T F S S
« Jun    
 123456
78910111213
14151617181920
21222324252627
28293031  

Posts by Month

Posts by Category