Better integration of online music players?

This is something I've been thinking a lot lately. I use online music players like LastFM and GrooveShark.

I want to be able to control such web apps with the multimedia keys, and I want a visual feedback to know which tab is generating sound.

"media" events

Here is an idea. What if we introduce a new kind of events. The "media" events.

I wrote some code to test this idea, here is a screencast, see below for the source code.

And since you can't see the Visual Feedback in the video, here is a screenshot:

Multimedia keys

Some media events would be fired if the user uses the media keys, even if the tab is on the background or your browser not focused.

  window.addEventListener("media",
    function(e) {
      // could be: play, pause, previous, next
      if (e.data == "play") {
        myplayer.play();
      }
  }, true);

Visual feedback

The browser could automatically detect if sound is being generated from the tab, and give a visual feedback. But it's something quite tricky (especially because of the plugins, see bug 486262 ).

So what about letting the web page notify the browser the some sound is being played, by firing a media event ("sound"/"nosound")?

What do you think

Does it make sense? What about the names of these events? Also, what happens if the user has different web pages listening to the media events?

Source code

Find the source code of this addon here. Works only on Linux (any port to Windows/Mac would be appreciated).

Update

26 Apr 2011 / tweet this / @paulrouget / show comments

Comments