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

Unified Diff: tools/dom/templates/html/impl/impl_Navigator.darttemplate

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/templates/html/impl/impl_MediaStream.darttemplate ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_Navigator.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_Navigator.darttemplate b/tools/dom/templates/html/impl/impl_Navigator.darttemplate
new file mode 100644
index 0000000000000000000000000000000000000000..f6d7b91fdcd07c0d5f9956215a1e3014b682a6a7
--- /dev/null
+++ b/tools/dom/templates/html/impl/impl_Navigator.darttemplate
@@ -0,0 +1,79 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of $LIBRARYNAME;
+$ANNOTATIONS
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+
+$if DART2JS
+ @DomName('Navigator.language')
+ String get language => JS('String', '#.language || #.userLanguage', this,
+ this);
+$endif
+
+ /**
+ * Gets a stream (video and or audio) from the local computer.
+ *
+ * Use [MediaStream.supported] to check if this is supported by the current
+ * platform.
+ *
+ * Example use:
+ *
+ * window.navigator.getUserMedia(audio:true, video: true).then((stream) {
+ * var video = new VideoElement()
+ * ..autoplay = true
+ * ..src = Url.createObjectUrl(stream);
+ * document.body.append(video);
+ * });
+ *
+ * See also:
+ * * [MediaStream.supported]
+ */
+ @DomName('Navigator.webkitGetUserMedia')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @Experimental()
+ Future<LocalMediaStream> getUserMedia({bool audio: false,
+ bool video: false}) {
+ var completer = new Completer<LocalMediaStream>();
+ var options = {
+ 'audio': audio,
+ 'video': video
+ };
+$if DART2JS
+ _ensureGetUserMedia();
+ this._getUserMedia(convertDartToNative_Dictionary(options),
+ (stream) {
+ completer.complete(stream);
+ },
+ (error) {
+ completer.completeError(error);
+ });
+$else
+ this._getUserMedia(options,
+ (stream) {
+ completer.complete(stream);
+ },
+ (error) {
+ completer.completeError(error);
+ });
+$endif
+ return completer.future;
+ }
+
+$if DART2JS
+ _ensureGetUserMedia() {
+ if (JS('bool', '!(#.getUserMedia)', this)) {
+ JS('void', '#.getUserMedia = '
+ '(#.getUserMedia || #.webkitGetUserMedia || #.mozGetUserMedia ||'
+ '#.msGetUserMedia)', this, this, this, this, this);
+ }
+ }
+
+ @JSName('getUserMedia')
+ void _getUserMedia(options, _NavigatorUserMediaSuccessCallback success,
+ _NavigatorUserMediaErrorCallback error) native;
+$endif
+
+$!MEMBERS
+}
« no previous file with comments | « tools/dom/templates/html/impl/impl_MediaStream.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698