Navigator class
@DomName('Navigator')
class Navigator native "Navigator" {
@DomName('Navigator.language')
String get language => JS('String', '#.language || #.userLanguage', this,
this);
/**
* Gets a stream (video and or audio) from the local computer.
*
* Use [MediaStream.supported] to check if this is supported by the current
* platform. The arguments `audio` and `video` default to `false` (stream does
* not use audio or video, respectively).
*
* Simple example usage:
*
* window.navigator.getUserMedia(audio: true, video: true).then((stream) {
* var video = new VideoElement()
* ..autoplay = true
* ..src = Url.createObjectUrl(stream);
* document.body.append(video);
* });
*
* The user can also pass in Maps to the audio or video parameters to specify
* mandatory and optional constraints for the media stream. Not passing in a
* map, but passing in `true` will provide a MediaStream with audio or
* video capabilities, but without any additional constraints. The particular
* constraint names for audio and video are still in flux, but as of this
* writing, here is an example providing more constraints.
*
* window.navigator.getUserMedia(
* audio: true,
* video: {'mandatory':
* { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 },
* 'optional':
* [{ 'minFrameRate': 60 },
* { 'maxWidth': 640 }]
* });
*
* See also:
* * [MediaStream.supported]
*/
@DomName('Navigator.webkitGetUserMedia')
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
Future<MediaStream> getUserMedia({audio: false, video: false}) {
var completer = new Completer<MediaStream>();
var options = {
'audio': audio,
'video': video
};
_ensureGetUserMedia();
this._getUserMedia(convertDartToNative_SerializedScriptValue(options),
(stream) {
completer.complete(stream);
},
(error) {
completer.completeError(error);
});
return completer.future;
}
_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;
@DomName('Navigator.appCodeName')
@DocsEditable
final String appCodeName;
@DomName('Navigator.appName')
@DocsEditable
final String appName;
@DomName('Navigator.appVersion')
@DocsEditable
final String appVersion;
@DomName('Navigator.cookieEnabled')
@DocsEditable
final bool cookieEnabled;
@DomName('Navigator.doNotTrack')
@DocsEditable
final String doNotTrack;
@DomName('Navigator.geolocation')
@DocsEditable
final Geolocation geolocation;
@DomName('Navigator.mimeTypes')
@DocsEditable
final MimeTypeArray mimeTypes;
@DomName('Navigator.onLine')
@DocsEditable
final bool onLine;
@DomName('Navigator.platform')
@DocsEditable
final String platform;
@DomName('Navigator.plugins')
@DocsEditable
final PluginArray plugins;
@DomName('Navigator.product')
@DocsEditable
final String product;
@DomName('Navigator.productSub')
@DocsEditable
final String productSub;
@DomName('Navigator.userAgent')
@DocsEditable
final String userAgent;
@DomName('Navigator.vendor')
@DocsEditable
final String vendor;
@DomName('Navigator.vendorSub')
@DocsEditable
final String vendorSub;
@JSName('webkitPersistentStorage')
@DomName('Navigator.webkitPersistentStorage')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
final StorageQuota persistentStorage;
@JSName('webkitTemporaryStorage')
@DomName('Navigator.webkitTemporaryStorage')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
final StorageQuota temporaryStorage;
@DomName('Navigator.getStorageUpdates')
@DocsEditable
void getStorageUpdates() native;
@DomName('Navigator.javaEnabled')
@DocsEditable
bool javaEnabled() native;
@DomName('Navigator.registerProtocolHandler')
@DocsEditable
void registerProtocolHandler(String scheme, String url, String title) native;
@JSName('webkitGetGamepads')
@DomName('Navigator.webkitGetGamepads')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
@Returns('_GamepadList')
@Creates('_GamepadList')
List<Gamepad> getGamepads() native;
}
Extends
Interceptor > Navigator
Properties
final String appCodeName #
final String appCodeName
final String appName #
final String appName
final String appVersion #
final String appVersion
final bool cookieEnabled #
final bool cookieEnabled
final String doNotTrack #
final String doNotTrack
final Geolocation geolocation #
final Geolocation geolocation
final int hashCode #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode it should override the
equality operator as well to maintain consistency.
int get hashCode => Primitives.objectHashCode(this);
final String language #
@DomName('Navigator.language')
String get language => JS('String', '#.language || #.userLanguage', this,
this);
final MimeTypeArray mimeTypes #
final MimeTypeArray mimeTypes
final bool onLine #
final bool onLine
final StorageQuota persistentStorage #
final StorageQuota persistentStorage
final String platform #
final String platform
final PluginArray plugins #
final PluginArray plugins
final String product #
final String product
final String productSub #
final String productSub
final Type runtimeType #
A representation of the runtime type of the object.
Type get runtimeType => getRuntimeType(this);
final StorageQuota temporaryStorage #
final StorageQuota temporaryStorage
final String userAgent #
final String userAgent
Operators
bool operator ==(other) #
The equality operator.
The default behavior for all Objects is to return true if and
only if this and
other are the same object.
If a subclass overrides the equality operator it should override
the hashCode method as well to maintain consistency.
bool operator ==(other) => identical(this, other);
Methods
List<Gamepad> getGamepads() #
@JSName('webkitGetGamepads')
@DomName('Navigator.webkitGetGamepads')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
@Returns('_GamepadList')
@Creates('_GamepadList')
List<Gamepad> getGamepads() native;
void getStorageUpdates() #
@DomName('Navigator.getStorageUpdates')
@DocsEditable
void getStorageUpdates() native;
Future<MediaStream> getUserMedia({audio: false, video: false}) #
Gets a stream (video and or audio) from the local computer.
Use MediaStream.supported to check if this is supported by the current
platform. The arguments audio and video default to false (stream does
not use audio or video, respectively).
Simple example usage:
window.navigator.getUserMedia(audio: true, video: true).then((stream) {
var video = new VideoElement()
..autoplay = true
..src = Url.createObjectUrl(stream);
document.body.append(video);
});
The user can also pass in Maps to the audio or video parameters to specify
mandatory and optional constraints for the media stream. Not passing in a
map, but passing in true will provide a MediaStream with audio or
video capabilities, but without any additional constraints. The particular
constraint names for audio and video are still in flux, but as of this
writing, here is an example providing more constraints.
window.navigator.getUserMedia(
audio: true,
video: {'mandatory':
{ 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 },
'optional':
[{ 'minFrameRate': 60 },
{ 'maxWidth': 640 }]
});
See also: * MediaStream.supported
@DomName('Navigator.webkitGetUserMedia')
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
Future<MediaStream> getUserMedia({audio: false, video: false}) {
var completer = new Completer<MediaStream>();
var options = {
'audio': audio,
'video': video
};
_ensureGetUserMedia();
this._getUserMedia(convertDartToNative_SerializedScriptValue(options),
(stream) {
completer.complete(stream);
},
(error) {
completer.completeError(error);
});
return completer.future;
}
bool javaEnabled() #
@DomName('Navigator.javaEnabled')
@DocsEditable
bool javaEnabled() native;
dynamic noSuchMethod(Invocation invocation) #
noSuchMethod is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to noSuchMethod in an Invocation.
If noSuchMethod returns a value, that value becomes the result of
the original invocation.
The default behavior of noSuchMethod is to throw a
noSuchMethodError.
dynamic noSuchMethod(Invocation invocation) {
throw new NoSuchMethodError(
this,
_symbolToString(invocation.memberName),
invocation.positionalArguments,
_symbolMapToStringMap(invocation.namedArguments));
}
This page includes content from the
Mozilla Foundation that is graciously
licensed under a
Creative Commons: Attribution-Sharealike license.
Mozilla has no other association with Dart or dartlang.org. We
encourage you to improve the web by
contributing to
The Mozilla Developer Network.