What is this site?

HTML5Labs is where Microsoft prototypes early and unstable specifications from web standards bodies such as W3C. Sharing these prototypes helps us have informed discussions with developer communities, and enables us to provide better feedback on draft specifications based on this implementation experience. To find out more about HTML5Labs, read the blog by Dean Hachamovitch, Corporate Vice President for Internet Explorer, and the blog by Jean Paoli, President, Microsoft Open Technologies, Inc.

Media Capture API

The prototype is based on the latest spec draft. Read the full specification here.

To understand the system requirements and limitations of the current prototype implementation, read the release notes here.

MediaCapture is one of the HTML 5 working specifications driven by the W3C WebApps working group to provides access to the audio, image and video capture capabilities of the device.

The following is a sample to show how the new APIs can be used to capture an Audio stream.

 

1:   this.captureAudio = function Capture_captureAudio(successCB, errorCB, audioOptions) {
2:
3:     // Validate the parameters
4:     if (typeof (successCB) != "function") {
5:         ParameterError("successCB");
6:         return;
7:     }
8:
9:     if (typeof (errorCB) != "function") {
10:         ParameterError("errorCB");
11:         return;
12:     }
13:
14:     if (typeof (audioOptions) != "object") {
15:         ParameterError("audioOptions");
16:         return;
17:     }
18:
19:     //(Validation of additional parameters omitted...)
20:
21:     this.SetCaptureProperties(successCB, errorCB, audioOptions);
22:    objMicrosoftMediaCapture.CaptureAudio(audioOptions.duration, audioOptions.limit, audioOptions.mode, audioOptions.sensitivity, audioOptions.initialTimeout, audioOptions.endTimeout);
23:
24:     var recsession = new PendingOperation();
25:     recsession.Cancel = this.Cancel;
26:     return recsession;
27: };
28: