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)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
8 | 8 |
9 $if DART2JS | |
10 @DomName('Navigator.language') | 9 @DomName('Navigator.language') |
11 String get language => JS('String', '#.language || #.userLanguage', this, | 10 String get language => JS('String', '#.language || #.userLanguage', this, |
12 this); | 11 this); |
13 $endif | |
14 | 12 |
15 /** | 13 /** |
16 * Gets a stream (video and or audio) from the local computer. | 14 * Gets a stream (video and or audio) from the local computer. |
17 * | 15 * |
18 * Use [MediaStream.supported] to check if this is supported by the current | 16 * Use [MediaStream.supported] to check if this is supported by the current |
19 * platform. The arguments `audio` and `video` default to `false` (stream does | 17 * platform. The arguments `audio` and `video` default to `false` (stream does |
20 * not use audio or video, respectively). | 18 * not use audio or video, respectively). |
21 * | 19 * |
22 * Simple example usage: | 20 * Simple example usage: |
23 * | 21 * |
(...skipping 25 matching lines...) Expand all Loading... |
49 */ | 47 */ |
50 @DomName('Navigator.webkitGetUserMedia') | 48 @DomName('Navigator.webkitGetUserMedia') |
51 @SupportedBrowser(SupportedBrowser.CHROME) | 49 @SupportedBrowser(SupportedBrowser.CHROME) |
52 @Experimental() | 50 @Experimental() |
53 Future<MediaStream> getUserMedia({audio: false, video: false}) { | 51 Future<MediaStream> getUserMedia({audio: false, video: false}) { |
54 var completer = new Completer<MediaStream>(); | 52 var completer = new Completer<MediaStream>(); |
55 var options = { | 53 var options = { |
56 'audio': audio, | 54 'audio': audio, |
57 'video': video | 55 'video': video |
58 }; | 56 }; |
59 $if DART2JS | |
60 _ensureGetUserMedia(); | 57 _ensureGetUserMedia(); |
61 this._getUserMedia(convertDartToNative_SerializedScriptValue(options), | 58 this._getUserMedia(convertDartToNative_SerializedScriptValue(options), |
62 (stream) { | 59 (stream) { |
63 completer.complete(stream); | 60 completer.complete(stream); |
64 }, | 61 }, |
65 (error) { | 62 (error) { |
66 completer.completeError(error); | 63 completer.completeError(error); |
67 }); | 64 }); |
68 $else | |
69 this._getUserMedia(options, | |
70 (stream) { | |
71 completer.complete(stream); | |
72 }, | |
73 (error) { | |
74 completer.completeError(error); | |
75 }); | |
76 $endif | |
77 return completer.future; | 65 return completer.future; |
78 } | 66 } |
79 | 67 |
80 $if DART2JS | |
81 _ensureGetUserMedia() { | 68 _ensureGetUserMedia() { |
82 if (JS('bool', '!(#.getUserMedia)', this)) { | 69 if (JS('bool', '!(#.getUserMedia)', this)) { |
83 JS('void', '#.getUserMedia = ' | 70 JS('void', '#.getUserMedia = ' |
84 '(#.getUserMedia || #.webkitGetUserMedia || #.mozGetUserMedia ||' | 71 '(#.getUserMedia || #.webkitGetUserMedia || #.mozGetUserMedia ||' |
85 '#.msGetUserMedia)', this, this, this, this, this); | 72 '#.msGetUserMedia)', this, this, this, this, this); |
86 } | 73 } |
87 } | 74 } |
88 | 75 |
89 @JSName('getUserMedia') | 76 @JSName('getUserMedia') |
90 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success, | 77 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success, |
91 _NavigatorUserMediaErrorCallback error) native; | 78 _NavigatorUserMediaErrorCallback error) native; |
92 $endif | |
93 | 79 |
94 $!MEMBERS | 80 $!MEMBERS |
95 } | 81 } |
OLD | NEW |