Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 12022027: Fixing up Navigator.getUserMedia. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library html; 1 library html;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'dart:collection-dev'; 5 import 'dart:collection-dev';
6 import 'dart:html_common'; 6 import 'dart:html_common';
7 import 'dart:indexed_db'; 7 import 'dart:indexed_db';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 14079 matching lines...) Expand 10 before | Expand all | Expand 10 after
14090 @DocsEditable @DomName('MediaSource.endOfStream') 14090 @DocsEditable @DomName('MediaSource.endOfStream')
14091 void endOfStream(String error) native; 14091 void endOfStream(String error) native;
14092 14092
14093 @JSName('removeEventListener') 14093 @JSName('removeEventListener')
14094 @DocsEditable @DomName('MediaSource.removeEventListener') 14094 @DocsEditable @DomName('MediaSource.removeEventListener')
14095 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native; 14095 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
14096 14096
14097 @DocsEditable @DomName('MediaSource.removeSourceBuffer') 14097 @DocsEditable @DomName('MediaSource.removeSourceBuffer')
14098 void removeSourceBuffer(SourceBuffer buffer) native; 14098 void removeSourceBuffer(SourceBuffer buffer) native;
14099 } 14099 }
14100 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 14100 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
14101 // for details. All rights reserved. Use of this source code is governed by a 14101 // for details. All rights reserved. Use of this source code is governed by a
14102 // BSD-style license that can be found in the LICENSE file. 14102 // BSD-style license that can be found in the LICENSE file.
14103 14103
14104 14104
14105 14105 /// @domName MediaStream; @docsEditable true
14106 @DocsEditable 14106 @DocsEditable
14107 @DomName('MediaStream') 14107 @DomName('MediaStream')
14108 class MediaStream extends EventTarget native "*MediaStream" { 14108 class MediaStream extends EventTarget native "*MediaStream" {
14109 14109
14110 static const EventStreamProvider<Event> endedEvent = const EventStreamProvider <Event>('ended'); 14110 static const EventStreamProvider<Event> endedEvent = const EventStreamProvider <Event>('ended');
14111 14111
14112 @DocsEditable 14112 @DocsEditable
14113 factory MediaStream() => MediaStream._create(); 14113 factory MediaStream() => MediaStream._create();
14114 static MediaStream _create() => JS('MediaStream', 'new MediaStream()'); 14114 static MediaStream _create() => JS('MediaStream', 'new MediaStream()');
14115 14115
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
14148 List<MediaStreamTrack> getVideoTracks() native; 14148 List<MediaStreamTrack> getVideoTracks() native;
14149 14149
14150 @JSName('removeEventListener') 14150 @JSName('removeEventListener')
14151 @DocsEditable @DomName('MediaStream.removeEventListener') 14151 @DocsEditable @DomName('MediaStream.removeEventListener')
14152 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native; 14152 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
14153 14153
14154 @DocsEditable @DomName('MediaStream.removeTrack') 14154 @DocsEditable @DomName('MediaStream.removeTrack')
14155 void removeTrack(MediaStreamTrack track) native; 14155 void removeTrack(MediaStreamTrack track) native;
14156 14156
14157 Stream<Event> get onEnded => endedEvent.forTarget(this); 14157 Stream<Event> get onEnded => endedEvent.forTarget(this);
14158
14159
14160 /**
14161 * Checks if the MediaStream APIs are supported on the current platform.
14162 *
14163 * See also:
14164 *
14165 * * [Navigator.getUserMedia]
14166 */
14167 static bool get supported =>
14168 JS('bool', '''!!(#.getUserMedia || #.webkitGetUserMedia ||
14169 #.mozGetUserMedia || #.msGetUserMedia)''',
14170 window.navigator,
14171 window.navigator,
14172 window.navigator,
14173 window.navigator);
14158 } 14174 }
14159 14175
14160 @DocsEditable 14176 @DocsEditable
14161 class MediaStreamEvents extends Events { 14177 class MediaStreamEvents extends Events {
14162 @DocsEditable 14178 @DocsEditable
14163 MediaStreamEvents(EventTarget _ptr) : super(_ptr); 14179 MediaStreamEvents(EventTarget _ptr) : super(_ptr);
14164 14180
14165 @DocsEditable 14181 @DocsEditable
14166 EventListenerList get addTrack => this['addtrack']; 14182 EventListenerList get addTrack => this['addtrack'];
14167 14183
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
15032 // BSD-style license that can be found in the LICENSE file. 15048 // BSD-style license that can be found in the LICENSE file.
15033 15049
15034 15050
15035 @DocsEditable 15051 @DocsEditable
15036 @DomName('Navigator') 15052 @DomName('Navigator')
15037 class Navigator native "*Navigator" { 15053 class Navigator native "*Navigator" {
15038 15054
15039 @DomName('Navigator.language') 15055 @DomName('Navigator.language')
15040 String get language => JS('String', '#.language || #.userLanguage', this, 15056 String get language => JS('String', '#.language || #.userLanguage', this,
15041 this); 15057 this);
15042 15058
15059 /**
15060 * Gets a stream (video and or audio) from the local computer.
15061 *
15062 * Use [MediaStream.supported] to check if this is supported by the current
15063 * platform.
15064 *
15065 * Example use:
15066 *
15067 * window.navigator.getUserMedia(audio:true, video: true).then((stream) {
15068 * var video = new VideoElement()
15069 * ..autoplay = true
15070 * ..src = Url.createObjectUrl(stream);
15071 * document.body.append(video);
15072 * });
15073 *
15074 * See also:
15075 * * [MediaStream.supported]
15076 */
15077 @DomName('Navigator.webkitGetUserMedia')
15078 @SupportedBrowser(SupportedBrowser.CHROME)
15079 @Experimental()
15080 Future<LocalMediaStream> getUserMedia({bool audio: false,
15081 bool video: false}) {
15082 var completer = new Completer<LocalMediaStream>();
15083 var options = {
15084 'audio': audio,
15085 'video': video
15086 };
15087 _ensureGetUserMedia();
15088 this._getUserMedia(convertDartToNative_Dictionary(options),
15089 (stream) {
15090 completer.complete(stream);
15091 },
15092 (error) {
15093 completer.completeError(error);
15094 });
15095 return completer.future;
15096 }
15097
15098 _ensureGetUserMedia() {
15099 if (JS('bool', '!(#.getUserMedia)', this)) {
15100 JS('void', '#.getUserMedia = '
15101 '(#.getUserMedia || #.webkitGetUserMedia || #.mozGetUserMedia ||'
15102 '#.msGetUserMedia)', this, this, this, this, this);
15103 }
15104 }
15105
15106 @JSName('getUserMedia')
15107 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success,
15108 _NavigatorUserMediaErrorCallback error) native;
15109
15110
15043 @DocsEditable @DomName('Navigator.appCodeName') 15111 @DocsEditable @DomName('Navigator.appCodeName')
15044 final String appCodeName; 15112 final String appCodeName;
15045 15113
15046 @DocsEditable @DomName('Navigator.appName') 15114 @DocsEditable @DomName('Navigator.appName')
15047 final String appName; 15115 final String appName;
15048 15116
15049 @DocsEditable @DomName('Navigator.appVersion') 15117 @DocsEditable @DomName('Navigator.appVersion')
15050 final String appVersion; 15118 final String appVersion;
15051 15119
15052 @DocsEditable @DomName('Navigator.cookieEnabled') 15120 @DocsEditable @DomName('Navigator.cookieEnabled')
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
15088 @DocsEditable @DomName('Navigator.getStorageUpdates') 15156 @DocsEditable @DomName('Navigator.getStorageUpdates')
15089 void getStorageUpdates() native; 15157 void getStorageUpdates() native;
15090 15158
15091 @DocsEditable @DomName('Navigator.javaEnabled') 15159 @DocsEditable @DomName('Navigator.javaEnabled')
15092 bool javaEnabled() native; 15160 bool javaEnabled() native;
15093 15161
15094 @DocsEditable @DomName('Navigator.webkitGetGamepads') 15162 @DocsEditable @DomName('Navigator.webkitGetGamepads')
15095 @Returns('_GamepadList') @Creates('_GamepadList') 15163 @Returns('_GamepadList') @Creates('_GamepadList')
15096 List<Gamepad> webkitGetGamepads() native; 15164 List<Gamepad> webkitGetGamepads() native;
15097 15165
15098 void webkitGetUserMedia(Map options, NavigatorUserMediaSuccessCallback success Callback, [NavigatorUserMediaErrorCallback errorCallback]) {
15099 if (?errorCallback) {
15100 var options_1 = convertDartToNative_Dictionary(options);
15101 _webkitGetUserMedia_1(options_1, successCallback, errorCallback);
15102 return;
15103 }
15104 var options_2 = convertDartToNative_Dictionary(options);
15105 _webkitGetUserMedia_2(options_2, successCallback);
15106 return;
15107 }
15108 @JSName('webkitGetUserMedia')
15109 @DocsEditable @DomName('Navigator.webkitGetUserMedia')
15110 void _webkitGetUserMedia_1(options, NavigatorUserMediaSuccessCallback successC allback, NavigatorUserMediaErrorCallback errorCallback) native;
15111 @JSName('webkitGetUserMedia')
15112 @DocsEditable @DomName('Navigator.webkitGetUserMedia')
15113 void _webkitGetUserMedia_2(options, NavigatorUserMediaSuccessCallback successC allback) native;
15114
15115 } 15166 }
15116 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 15167 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
15117 // for details. All rights reserved. Use of this source code is governed by a 15168 // for details. All rights reserved. Use of this source code is governed by a
15118 // BSD-style license that can be found in the LICENSE file. 15169 // BSD-style license that can be found in the LICENSE file.
15119 15170
15120 15171
15121 15172
15122 @DocsEditable 15173 @DocsEditable
15123 @DomName('NavigatorUserMediaError') 15174 @DomName('NavigatorUserMediaError')
15124 class NavigatorUserMediaError native "*NavigatorUserMediaError" { 15175 class NavigatorUserMediaError native "*NavigatorUserMediaError" {
15125 15176
15126 static const int PERMISSION_DENIED = 1; 15177 static const int PERMISSION_DENIED = 1;
15127 15178
15128 @DocsEditable @DomName('NavigatorUserMediaError.code') 15179 @DocsEditable @DomName('NavigatorUserMediaError.code')
15129 final int code; 15180 final int code;
15130 } 15181 }
15131 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 15182 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
15132 // for details. All rights reserved. Use of this source code is governed by a 15183 // for details. All rights reserved. Use of this source code is governed by a
15133 // BSD-style license that can be found in the LICENSE file. 15184 // BSD-style license that can be found in the LICENSE file.
15134 15185
15135 // WARNING: Do not edit - generated code. 15186 // WARNING: Do not edit - generated code.
15136 15187
15137 15188
15138 typedef void NavigatorUserMediaErrorCallback(NavigatorUserMediaError error); 15189 typedef void _NavigatorUserMediaErrorCallback(NavigatorUserMediaError error);
15139 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 15190 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
15140 // for details. All rights reserved. Use of this source code is governed by a 15191 // for details. All rights reserved. Use of this source code is governed by a
15141 // BSD-style license that can be found in the LICENSE file. 15192 // BSD-style license that can be found in the LICENSE file.
15142 15193
15143 // WARNING: Do not edit - generated code. 15194 // WARNING: Do not edit - generated code.
15144 15195
15145 15196
15146 typedef void NavigatorUserMediaSuccessCallback(LocalMediaStream stream); 15197 typedef void _NavigatorUserMediaSuccessCallback(LocalMediaStream stream);
15147 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 15198 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
15148 // for details. All rights reserved. Use of this source code is governed by a 15199 // for details. All rights reserved. Use of this source code is governed by a
15149 // BSD-style license that can be found in the LICENSE file. 15200 // BSD-style license that can be found in the LICENSE file.
15150 15201
15151 15202
15152 /** 15203 /**
15153 * Lazy implementation of the child nodes of an element that does not request 15204 * Lazy implementation of the child nodes of an element that does not request
15154 * the actual child nodes of an element until strictly necessary greatly 15205 * the actual child nodes of an element until strictly necessary greatly
15155 * improving performance for the typical cases where it is not required. 15206 * improving performance for the typical cases where it is not required.
15156 */ 15207 */
(...skipping 14192 matching lines...) Expand 10 before | Expand all | Expand 10 after
29349 _position = nextPosition; 29400 _position = nextPosition;
29350 return true; 29401 return true;
29351 } 29402 }
29352 _current = null; 29403 _current = null;
29353 _position = _array.length; 29404 _position = _array.length;
29354 return false; 29405 return false;
29355 } 29406 }
29356 29407
29357 T get current => _current; 29408 T get current => _current;
29358 } 29409 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698