| 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
|
| +}
|
|
|