Web applications are increasingly taking over the functions of native applications. This year has seen an increase of (streaming) audio web applications, such as Rdio, Spotify, Pandora, etc. These applications are long-running applications and provide multimedia to the user, often while the user is doing something else.
Interaction with this type of application works the same as with other applications: the user brings the tab/window in focus and manipulates the application through mouse, keyboard or other input device. Bringing the application into focus is required in order to interact with the application and thus requires the user to get out of the current workflow.
In native applications this problem is fixed by letting applications bind to specific multimedia buttons situated on the keyboard. These buttons serve as a way to interact with the media player without bringing the application into focus. This is currently impossible for web applications for the following reasons:
- A window has to be in focus in order to capture a
KeyboardEvent
. - Multimedia keys won't reach the browser, because multimedia buttons are bound to other media players (e.g iTunes on OS X, even if iTunes isn't running.)
Boris Smus put some work into a Chrome Extension which inserts a script into each tab, capturing the events and relaying the events to a player. In a later iteration he wrote a small native application which captures the keyboard events and runs a WebSocket server. An accomapanying Chrome Extension runs a WebSocket client which receives these events. The advantage of the latter approach is that the browser doesn't have to be in focus in order to manipulate the player.
- @domenic pointed out that there is already some work done in the DOM level 3 spec for mapping events from multimedia keys (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names_and_Char_values, search for _MEDIA).
- @annevk mentions the asking [email protected] is probably a better way to go, because there is where most of the UI events things happen.