1,836 bytes added,
00:24, 7 July 2009 == JEP 18 - Audio ==
* Champion: Anant Narayanan <anant at mozilla dot com>
* Status: Implementing
* Type: API Track
* Created: 6 July 2009
* Reference Implementation: jetpack.future.import("audio")
* [[Labs/Jetpack/JEPs|JEP Index]]
=== Introduction and Rationale ===
The Audio module allows the developer to record audio to an Ogg/Vorbis file in the browser. In the future, we also plan on adding capability for processing that audio and encoding it into files.
=== Proposal ===
The Audio module will be available under <code>jetpack.audio</code>
To begin recording to a file, call: <code>jetpack.audio.recordToFile</code>.
To stop the recording, call: <code>jetpack.audio.stopRecording</code. This function will return the path of the Ogg/Vorbis file that the audio was recorded to.
To check if a recording is in progress (simultaneous recording of audio is not allowed), access the <code>jetpack.audio.isRecording</code> property.
=== Example ===
This Jetpack shows a 'Record' button on the status bar, which when clicked will start recording audio to a file. On clicking it again, the recording is stopped, a notification with the file path is displayed and the audio is played back.
<pre class="brush:js;toolbar:false;">
var path = '';
jetpack.future.import('audio');
jetpack.statusBar.append({
html: 'Record<i>!</i>',
width: 55,
onReady: function(w) {
$(w).click(function() {
if (jetpack.audio.isRecording) {
path = jetpack.audio.stopRecording();
jetpack.notifications.show("Saved to " + path + ", now playing!");
$(jetpack.tabs.focused.contentDocument).find('body').
append('<audio src="file://'+path+'" autoplay="true"></audio>');
} else {
jetpack.notifications.show("Recording...");
jetpack.audio.recordToFile();
}
});
}
});
</pre>