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

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

Issue 11818066: Fixing up Navigator.getUserMedia. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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:html_common'; 5 import 'dart:html_common';
6 import 'dart:indexed_db'; 6 import 'dart:indexed_db';
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 import 'dart:json' as json; 8 import 'dart:json' as json;
9 import 'dart:math'; 9 import 'dart:math';
10 import 'dart:svg' as svg; 10 import 'dart:svg' as svg;
(...skipping 13383 matching lines...) Expand 10 before | Expand all | Expand 10 after
13394 /// @domName MediaSource.endOfStream; @docsEditable true 13394 /// @domName MediaSource.endOfStream; @docsEditable true
13395 void endOfStream(String error) native; 13395 void endOfStream(String error) native;
13396 13396
13397 /// @domName MediaSource.removeEventListener; @docsEditable true 13397 /// @domName MediaSource.removeEventListener; @docsEditable true
13398 @JSName('removeEventListener') 13398 @JSName('removeEventListener')
13399 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native; 13399 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
13400 13400
13401 /// @domName MediaSource.removeSourceBuffer; @docsEditable true 13401 /// @domName MediaSource.removeSourceBuffer; @docsEditable true
13402 void removeSourceBuffer(SourceBuffer buffer) native; 13402 void removeSourceBuffer(SourceBuffer buffer) native;
13403 } 13403 }
13404 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 13404 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
13405 // for details. All rights reserved. Use of this source code is governed by a 13405 // for details. All rights reserved. Use of this source code is governed by a
13406 // BSD-style license that can be found in the LICENSE file. 13406 // BSD-style license that can be found in the LICENSE file.
13407 13407
13408 13408
13409 /// @domName MediaStream; @docsEditable true 13409 /// @domName MediaStream; @docsEditable true
13410 class MediaStream extends EventTarget native "*MediaStream" { 13410 class MediaStream extends EventTarget native "*MediaStream" {
13411 13411
13412 ///@docsEditable true 13412 ///@docsEditable true
13413 factory MediaStream(MediaStreamTrackList audioTracks, MediaStreamTrackList vid eoTracks) => MediaStream._create(audioTracks, videoTracks); 13413 factory MediaStream(MediaStreamTrackList audioTracks, MediaStreamTrackList vid eoTracks) => MediaStream._create(audioTracks, videoTracks);
13414 static MediaStream _create(MediaStreamTrackList audioTracks, MediaStreamTrackL ist videoTracks) => JS('MediaStream', 'new MediaStream(#,#)', audioTracks, video Tracks); 13414 static MediaStream _create(MediaStreamTrackList audioTracks, MediaStreamTrackL ist videoTracks) => JS('MediaStream', 'new MediaStream(#,#)', audioTracks, video Tracks);
(...skipping 22 matching lines...) Expand all
13437 @JSName('addEventListener') 13437 @JSName('addEventListener')
13438 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native; 13438 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native;
13439 13439
13440 /// @domName MediaStream.dispatchEvent; @docsEditable true 13440 /// @domName MediaStream.dispatchEvent; @docsEditable true
13441 @JSName('dispatchEvent') 13441 @JSName('dispatchEvent')
13442 bool $dom_dispatchEvent(Event event) native; 13442 bool $dom_dispatchEvent(Event event) native;
13443 13443
13444 /// @domName MediaStream.removeEventListener; @docsEditable true 13444 /// @domName MediaStream.removeEventListener; @docsEditable true
13445 @JSName('removeEventListener') 13445 @JSName('removeEventListener')
13446 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native; 13446 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
13447
13448
13449 /**
13450 * Checks if the MediaStream APIs are supported on the current platform.
13451 *
13452 * See also:
13453 *
13454 * * [Navigator.getUserMedia]
13455 */
13456 static bool get supported =>
13457 JS('bool', '''!!(#.getUserMedia || #.webkitGetUserMedia ||
13458 #.mozGetUserMedia || #.msGetUserMedia)''',
13459 window.navigator,
13460 window.navigator,
13461 window.navigator,
13462 window.navigator);
13447 } 13463 }
13448 13464
13449 /// @docsEditable true 13465 /// @docsEditable true
13450 class MediaStreamEvents extends Events { 13466 class MediaStreamEvents extends Events {
13451 /// @docsEditable true 13467 /// @docsEditable true
13452 MediaStreamEvents(EventTarget _ptr) : super(_ptr); 13468 MediaStreamEvents(EventTarget _ptr) : super(_ptr);
13453 13469
13454 /// @docsEditable true 13470 /// @docsEditable true
13455 EventListenerList get ended => this['ended']; 13471 EventListenerList get ended => this['ended'];
13456 } 13472 }
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
14301 // BSD-style license that can be found in the LICENSE file. 14317 // BSD-style license that can be found in the LICENSE file.
14302 14318
14303 14319
14304 /// @domName Navigator; @docsEditable true 14320 /// @domName Navigator; @docsEditable true
14305 class Navigator native "*Navigator" { 14321 class Navigator native "*Navigator" {
14306 14322
14307 /// @domName Navigator.language; @docsEditable true 14323 /// @domName Navigator.language; @docsEditable true
14308 String get language => JS('String', '#.language || #.userLanguage', this, 14324 String get language => JS('String', '#.language || #.userLanguage', this,
14309 this); 14325 this);
14310 14326
14327 /**
14328 * Gets a stream (video and or audio) from the local computer.
14329 *
14330 * Use [MediaStream.supported] to check if this is supported by the current
14331 * platform.
14332 *
14333 * Example use:
14334 *
14335 * window.navigator.getUserMedia(audio:true, video: true).then((stream) {
14336 * var video = new VideoElement()
14337 * ..autoplay = true
14338 * ..src = Url.createObjectUrl(stream);
14339 * document.body.append(video);
14340 * });
14341 *
14342 * See also:
14343 * * [MediaStream.supported]
14344 */
14345 @SupportedBrowser(SupportedBrowser.CHROME)
14346 @Experimental()
14347 Future<LocalMediaStream> getUserMedia({bool audio=false, bool video=false}) {
14348 var completer = new Completer<LocalMediaStream>();
14349 var options = {
14350 'audio': audio,
14351 'video': video
14352 };
14353 _ensureGetUserMedia();
14354 this._getUserMedia(convertDartToNative_Dictionary(options),
14355 (stream) {
14356 completer.complete(stream);
14357 },
14358 (error) {
14359 completer.completeError(error);
14360 });
14361 return completer.future;
14362 }
14363
14364 _ensureGetUserMedia() {
14365 if (JS('bool', '!(#.getUserMedia)', this)) {
14366 JS('void', '#.getUserMedia = '
14367 '(#.getUserMedia || #.webkitGetUserMedia || #.mozGetUserMedia ||'
14368 '#.msGetUserMedia)', this, this, this, this, this);
14369 }
14370 }
14371
14372 @JSName('getUserMedia')
14373 void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success,
14374 _NavigatorUserMediaErrorCallback error) native;
14375
14376
14311 /// @domName Navigator.appCodeName; @docsEditable true 14377 /// @domName Navigator.appCodeName; @docsEditable true
14312 final String appCodeName; 14378 final String appCodeName;
14313 14379
14314 /// @domName Navigator.appName; @docsEditable true 14380 /// @domName Navigator.appName; @docsEditable true
14315 final String appName; 14381 final String appName;
14316 14382
14317 /// @domName Navigator.appVersion; @docsEditable true 14383 /// @domName Navigator.appVersion; @docsEditable true
14318 final String appVersion; 14384 final String appVersion;
14319 14385
14320 /// @domName Navigator.cookieEnabled; @docsEditable true 14386 /// @domName Navigator.cookieEnabled; @docsEditable true
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
14356 /// @domName Navigator.getStorageUpdates; @docsEditable true 14422 /// @domName Navigator.getStorageUpdates; @docsEditable true
14357 void getStorageUpdates() native; 14423 void getStorageUpdates() native;
14358 14424
14359 /// @domName Navigator.javaEnabled; @docsEditable true 14425 /// @domName Navigator.javaEnabled; @docsEditable true
14360 bool javaEnabled() native; 14426 bool javaEnabled() native;
14361 14427
14362 /// @domName Navigator.webkitGetGamepads; @docsEditable true 14428 /// @domName Navigator.webkitGetGamepads; @docsEditable true
14363 @Returns('_GamepadList') @Creates('_GamepadList') 14429 @Returns('_GamepadList') @Creates('_GamepadList')
14364 List<Gamepad> webkitGetGamepads() native; 14430 List<Gamepad> webkitGetGamepads() native;
14365 14431
14366 /// @domName Navigator.webkitGetUserMedia; @docsEditable true
14367 void webkitGetUserMedia(Map options, NavigatorUserMediaSuccessCallback success Callback, [NavigatorUserMediaErrorCallback errorCallback]) {
14368 if (?errorCallback) {
14369 var options_1 = convertDartToNative_Dictionary(options);
14370 _webkitGetUserMedia_1(options_1, successCallback, errorCallback);
14371 return;
14372 }
14373 var options_2 = convertDartToNative_Dictionary(options);
14374 _webkitGetUserMedia_2(options_2, successCallback);
14375 return;
14376 }
14377 @JSName('webkitGetUserMedia')
14378 void _webkitGetUserMedia_1(options, NavigatorUserMediaSuccessCallback successC allback, NavigatorUserMediaErrorCallback errorCallback) native;
14379 @JSName('webkitGetUserMedia')
14380 void _webkitGetUserMedia_2(options, NavigatorUserMediaSuccessCallback successC allback) native;
14381
14382 } 14432 }
14383 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 14433 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14384 // for details. All rights reserved. Use of this source code is governed by a 14434 // for details. All rights reserved. Use of this source code is governed by a
14385 // BSD-style license that can be found in the LICENSE file. 14435 // BSD-style license that can be found in the LICENSE file.
14386 14436
14387 14437
14388 /// @domName NavigatorUserMediaError; @docsEditable true 14438 /// @domName NavigatorUserMediaError; @docsEditable true
14389 class NavigatorUserMediaError native "*NavigatorUserMediaError" { 14439 class NavigatorUserMediaError native "*NavigatorUserMediaError" {
14390 14440
14391 static const int PERMISSION_DENIED = 1; 14441 static const int PERMISSION_DENIED = 1;
14392 14442
14393 /// @domName NavigatorUserMediaError.code; @docsEditable true 14443 /// @domName NavigatorUserMediaError.code; @docsEditable true
14394 final int code; 14444 final int code;
14395 } 14445 }
14396 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 14446 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14397 // for details. All rights reserved. Use of this source code is governed by a 14447 // for details. All rights reserved. Use of this source code is governed by a
14398 // BSD-style license that can be found in the LICENSE file. 14448 // BSD-style license that can be found in the LICENSE file.
14399 14449
14400 // WARNING: Do not edit - generated code. 14450 // WARNING: Do not edit - generated code.
14401 14451
14402 14452
14403 typedef void NavigatorUserMediaErrorCallback(NavigatorUserMediaError error); 14453 typedef void _NavigatorUserMediaErrorCallback(NavigatorUserMediaError error);
14404 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 14454 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14405 // for details. All rights reserved. Use of this source code is governed by a 14455 // for details. All rights reserved. Use of this source code is governed by a
14406 // BSD-style license that can be found in the LICENSE file. 14456 // BSD-style license that can be found in the LICENSE file.
14407 14457
14408 // WARNING: Do not edit - generated code. 14458 // WARNING: Do not edit - generated code.
14409 14459
14410 14460
14411 typedef void NavigatorUserMediaSuccessCallback(LocalMediaStream stream); 14461 typedef void _NavigatorUserMediaSuccessCallback(LocalMediaStream stream);
14412 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 14462 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14413 // for details. All rights reserved. Use of this source code is governed by a 14463 // for details. All rights reserved. Use of this source code is governed by a
14414 // BSD-style license that can be found in the LICENSE file. 14464 // BSD-style license that can be found in the LICENSE file.
14415 14465
14416 14466
14417 /** 14467 /**
14418 * Lazy implementation of the child nodes of an element that does not request 14468 * Lazy implementation of the child nodes of an element that does not request
14419 * the actual child nodes of an element until strictly necessary greatly 14469 * the actual child nodes of an element until strictly necessary greatly
14420 * improving performance for the typical cases where it is not required. 14470 * improving performance for the typical cases where it is not required.
14421 */ 14471 */
(...skipping 12515 matching lines...) Expand 10 before | Expand all | Expand 10 after
26937 _position = nextPosition; 26987 _position = nextPosition;
26938 return true; 26988 return true;
26939 } 26989 }
26940 _current = null; 26990 _current = null;
26941 _position = _array.length; 26991 _position = _array.length;
26942 return false; 26992 return false;
26943 } 26993 }
26944 26994
26945 T get current => _current; 26995 T get current => _current;
26946 } 26996 }
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