| 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` (stream does |
| 20 * not use audio or video, respectively). |
| 20 * | 21 * |
| 21 * Example use: | 22 * Simple example usage: |
| 22 * | 23 * |
| 23 * window.navigator.getUserMedia(audio:true, video: true).then((stream) { | 24 * window.navigator.getUserMedia(audio: true, video: true).then((stream) { |
| 24 * var video = new VideoElement() | 25 * var video = new VideoElement() |
| 25 * ..autoplay = true | 26 * ..autoplay = true |
| 26 * ..src = Url.createObjectUrl(stream); | 27 * ..src = Url.createObjectUrl(stream); |
| 27 * document.body.append(video); | 28 * document.body.append(video); |
| 28 * }); | 29 * }); |
| 29 * | 30 * |
| 31 * The user can also pass in Maps to the audio or video parameters to specify |
| 32 * mandatory and optional constraints for the media stream. Not passing in a |
| 33 * map, but passing in `true` will provide a LocalMediaStream with audio or |
| 34 * video capabilities, but without any additional constraints. The particular |
| 35 * constraint names for audio and video are still in flux, but as of this |
| 36 * writing, here is an example providing more constraints. |
| 37 * |
| 38 * window.navigator.getUserMedia( |
| 39 * audio: true, |
| 40 * video: {'mandatory': |
| 41 * { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 }, |
| 42 * 'optional': |
| 43 * [{ 'minFrameRate': 60 }, |
| 44 * { 'maxWidth': 640 }] |
| 45 * }); |
| 46 * |
| 30 * See also: | 47 * See also: |
| 31 * * [MediaStream.supported] | 48 * * [MediaStream.supported] |
| 32 */ | 49 */ |
| 33 @DomName('Navigator.webkitGetUserMedia') | 50 @DomName('Navigator.webkitGetUserMedia') |
| 34 @SupportedBrowser(SupportedBrowser.CHROME) | 51 @SupportedBrowser(SupportedBrowser.CHROME) |
| 35 @Experimental | 52 @Experimental |
| 36 Future<LocalMediaStream> getUserMedia({bool audio: false, | 53 Future<LocalMediaStream> getUserMedia({audio: false, video: false}) { |
| 37 bool video: false}) { | |
| 38 var completer = new Completer<LocalMediaStream>(); | 54 var completer = new Completer<LocalMediaStream>(); |
| 39 var options = { | 55 var options = { |
| 40 'audio': audio, | 56 'audio': audio, |
| 41 'video': video | 57 'video': video |
| 42 }; | 58 }; |
| 43 $if DART2JS | 59 $if DART2JS |
| 44 _ensureGetUserMedia(); | 60 _ensureGetUserMedia(); |
| 45 this._getUserMedia(convertDartToNative_Dictionary(options), | 61 this._getUserMedia(convertDartToNative_SerializedScriptValue(options), |
| 46 (stream) { | 62 (stream) { |
| 47 completer.complete(stream); | 63 completer.complete(stream); |
| 48 }, | 64 }, |
| 49 (error) { | 65 (error) { |
| 50 completer.completeError(error); | 66 completer.completeError(error); |
| 51 }); | 67 }); |
| 52 $else | 68 $else |
| 53 this._getUserMedia(options, | 69 this._getUserMedia(options, |
| 54 (stream) { | 70 (stream) { |
| 55 completer.complete(stream); | 71 completer.complete(stream); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 } | 86 } |
| 71 } | 87 } |
| 72 | 88 |
| 73 @JSName('getUserMedia') | 89 @JSName('getUserMedia') |
| 74 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success, | 90 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success, |
| 75 _NavigatorUserMediaErrorCallback error) native; | 91 _NavigatorUserMediaErrorCallback error) native; |
| 76 $endif | 92 $endif |
| 77 | 93 |
| 78 $!MEMBERS | 94 $!MEMBERS |
| 79 } | 95 } |
| OLD | NEW |