Dart API Referencedart:htmlNavigator

Navigator class

Returns a reference to the navigator object, which can be queried for information about the application running the script.
@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 #

Returns the internal "code" name of the current browser. Do not rely on this property to return the correct value.
final String appCodeName

final String appName #

Returns the official name of the browser. Do not rely on this property to return the correct value.
final String appName

final String appVersion #

Returns the version of the browser as a string. Do not rely on this property to return the correct value.
final String appVersion

final bool cookieEnabled #

Returns a boolean indicating whether cookies are enabled in the browser or not.
final bool cookieEnabled

final String doNotTrack #

Reports the value of the user's do-not-track preference. When this value is "yes", your web site or application should not track the user.
final String doNotTrack

final Geolocation geolocation #

final Geolocation geolocation

final int hashCode #

inherited from Interceptor

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.

docs inherited from Object
int get hashCode => Primitives.objectHashCode(this);

final String language #

Returns a string representing the language version of the browser.
@DomName('Navigator.language')
String get language => JS('String', '#.language || #.userLanguage', this,
   this);

final MimeTypeArray mimeTypes #

Returns a list of the MIME types supported by the browser.
final MimeTypeArray mimeTypes

final bool onLine #

Returns a boolean indicating whether the browser is working online.
final bool onLine

final StorageQuota persistentStorage #

final StorageQuota persistentStorage

final String platform #

Returns a string representing the platform of the browser.
final String platform

final PluginArray plugins #

Returns an array of the plugins installed in the browser.
final PluginArray plugins

final String product #

Returns the product name of the current browser. (e.g. "Gecko")
final String product

final String productSub #

Returns the build number of the current browser (e.g. "20060909")
final String productSub

final Type runtimeType #

inherited from Interceptor

A representation of the runtime type of the object.

docs inherited from Object
Type get runtimeType => getRuntimeType(this);

final StorageQuota temporaryStorage #

final StorageQuota temporaryStorage

final String userAgent #

Returns the user agent string for the current browser.
final String userAgent

final String vendor #

Returns the vendor name of the current browser (e.g. "Netscape6")
final String vendor

final String vendorSub #

Returns the vendor version number (e.g. "6.1")
final String vendorSub

Operators

bool operator ==(other) #

inherited from Interceptor

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.

docs inherited from Object
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() #

Indicates whether the host browser is Java-enabled or not.
@DomName('Navigator.javaEnabled')
@DocsEditable
bool javaEnabled() native;

dynamic noSuchMethod(Invocation invocation) #

inherited from Interceptor

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.

docs inherited from Object
dynamic noSuchMethod(Invocation invocation) {
 throw new NoSuchMethodError(
     this,
     _symbolToString(invocation.memberName),
     invocation.positionalArguments,
     _symbolMapToStringMap(invocation.namedArguments));
}

void registerProtocolHandler(String scheme, String url, String title) #

Allows web sites to register themselves as a possible handler for a given protocol.
@DomName('Navigator.registerProtocolHandler')
@DocsEditable
void registerProtocolHandler(String scheme, String url, String title) native;

String toString() #

inherited from Interceptor

Returns a string representation of this object.

docs inherited from Object
String toString() => Primitives.objectToString(this);

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.