Wednesday, July 22nd, 2009
Jetpack to the future with recording Audio API
<p>The Jetpack project is still a young 'un from Mozilla Labs (disclaimer: I work for labs!) but they are moving swiftly indeed, and each new release has a wicked cool new API that let's you do something you couldn't easily do before.With the Jetpack 0.4 release we see two cool APIs:
We have a shiny new <audio> tag which is great for playing audio and all, but how about adding the ability for users to easily create audio?
The new Audio Recording API lets you do just that:
-
-
jetpack.future.import('audio');
-
jetpack.audio.recordToFile();
-
var path = jetpack.audio.stopRecording();
-
Play the local file back with jetpack.audio.playFile() or upload it and just use the audio tag itself.

A great showcase of this is the voice memo jetpack "which lets you annotate any webpage you are looking at with your voice." Live streaming is even coming soon. Here comes video conferencing the Open Web way?
Jetpack is a great way to do Greasemonkey-like work. To make it even easier, you need a way to define when the jetpack kicks in etc, and this is exactly what the Page Mods API gives you.
Check out the blacklist example:
-
-
jetpack.future.import("pageMods");
-
-
var callback = function(document){
-
// check the current time if it is between 9 and 5
-
// 'blacklist' the sites in options.matches
-
var currentTime;
-
var currentHour;
-
currentTime = new Date();
-
currentHour = currentTime.getHours();
-
if (currentHour> 8 && currentHour <17){
-
document.title = "This site is blacklisted. Get some work done!";
-
$(document).find("body").children().hide();
-
$(document).find("body").prepend($('<h1>Sorry this site is blacklisted until 17:00. sadface.'));
-
}
-
-
};
-
-
var options = {};
-
options.matches = ["http://*.reddit.com/*",
-
"http://*.cnn.com/*",
-
"http://*.bbc.co.uk/*",
-
"http://*.dpreview.com/*",
-
"http://dpreview.com/*",
-
"http://*.bloglines.com/*",
-
"http://bloglines.com/*"];
-
jetpack.pageMods.add(callback, options);
-
Nice work guys.
Related Content:











Very cool!
Does this require firefogg, or is that built into Firefox 3.5 and/or JetPack?
@CaptainN you have to download and install a 3rd party plugin, something like grease monkey but better. Personally i think its not very useful if its not native to the browsers.
I agree
very cool