Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 8 | 8 |
| 9 $if DART2JS | 9 $if DART2JS |
| 10 @DomName('Navigator.language') | 10 @DomName('Navigator.language') |
| 11 String get language => JS('String', '#.language || #.userLanguage', this, | 11 String get language => JS('String', '#.language || #.userLanguage', this, |
| 12 this); | 12 this); |
| 13 $endif | 13 $endif |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Gets a stream (video and or audio) from the local computer. | 16 * Gets a stream (video and or audio) from the local computer. |
| 17 * | 17 * |
| 18 * Use [MediaStream.supported] to check if this is supported by the current | 18 * Use [MediaStream.supported] to check if this is supported by the current |
| 19 * platform. | 19 * platform. The arguments `audio` and `video` default to `false` (no |
| 20 * constraints), but will accept Maps in each parameter to specify mandatory | |
| 21 * and optional constraints for the media stream. Not passing in a map, but | |
| 22 * passing in `true` will provide a LocalMediaStream with audio or video | |
| 23 * capabilities, but without any additional constraints. | |
| 20 * | 24 * |
| 21 * Example use: | 25 * Example use: |
| 22 * | 26 * |
| 23 * window.navigator.getUserMedia(audio:true, video: true).then((stream) { | 27 * window.navigator.getUserMedia( |
| 28 * audio: true, | |
| 29 * video: {'mandatory': | |
|
blois
2013/03/19 20:35:23
It would be nice to move the details into a separa
| |
| 30 * { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 }, | |
| 31 * 'optional': | |
| 32 * [{ 'minFrameRate': 60 }, | |
| 33 * { 'maxWidth': 640 }] | |
| 34 * }).then((stream) { | |
| 24 * var video = new VideoElement() | 35 * var video = new VideoElement() |
| 25 * ..autoplay = true | 36 * ..autoplay = true |
| 26 * ..src = Url.createObjectUrl(stream); | 37 * ..src = Url.createObjectUrl(stream); |
| 27 * document.body.append(video); | 38 * document.body.append(video); |
| 28 * }); | 39 * }); |
| 29 * | 40 * |
| 30 * See also: | 41 * See also: |
| 31 * * [MediaStream.supported] | 42 * * [MediaStream.supported] |
| 32 */ | 43 */ |
| 33 @DomName('Navigator.webkitGetUserMedia') | 44 @DomName('Navigator.webkitGetUserMedia') |
| 34 @SupportedBrowser(SupportedBrowser.CHROME) | 45 @SupportedBrowser(SupportedBrowser.CHROME) |
| 35 @Experimental | 46 @Experimental |
| 36 Future<LocalMediaStream> getUserMedia({bool audio: false, | 47 Future<LocalMediaStream> getUserMedia({audio: false, |
| 37 bool video: false}) { | 48 video: false}) { |
| 38 var completer = new Completer<LocalMediaStream>(); | 49 var completer = new Completer<LocalMediaStream>(); |
| 39 var options = { | 50 var options = { |
| 40 'audio': audio, | 51 'audio': audio, |
| 41 'video': video | 52 'video': video |
| 42 }; | 53 }; |
| 43 $if DART2JS | 54 $if DART2JS |
| 44 _ensureGetUserMedia(); | 55 _ensureGetUserMedia(); |
| 45 this._getUserMedia(convertDartToNative_Dictionary(options), | 56 this._getUserMedia(convertDartToNative_SerializedScriptValue(options), |
| 46 (stream) { | 57 (stream) { |
| 47 completer.complete(stream); | 58 completer.complete(stream); |
| 48 }, | 59 }, |
| 49 (error) { | 60 (error) { |
| 50 completer.completeError(error); | 61 completer.completeError(error); |
| 51 }); | 62 }); |
| 52 $else | 63 $else |
| 53 this._getUserMedia(options, | 64 this._getUserMedia(options, |
| 54 (stream) { | 65 (stream) { |
| 55 completer.complete(stream); | 66 completer.complete(stream); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 70 } | 81 } |
| 71 } | 82 } |
| 72 | 83 |
| 73 @JSName('getUserMedia') | 84 @JSName('getUserMedia') |
| 74 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success, | 85 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success, |
| 75 _NavigatorUserMediaErrorCallback error) native; | 86 _NavigatorUserMediaErrorCallback error) native; |
| 76 $endif | 87 $endif |
| 77 | 88 |
| 78 $!MEMBERS | 89 $!MEMBERS |
| 79 } | 90 } |
| OLD | NEW |