FORGE. Device

new Device()

Manage Devices inside FORGE.
Device is singleton, so if you have multiple instances in the same page you MUST avoid UID conflict.
Source:

Extends

Members

(readonly) aac :boolean

Can play aac files?
Type:
  • boolean
Source:

(readonly) addEventListener :boolean

Is native support of addEventListener available?
Type:
  • boolean
Source:

(readonly) alive :boolean

Get the alive flag value of the object.
Type:
  • boolean
Inherited From:
Source:

(readonly) android :boolean

Is running on android?
Type:
  • boolean
Source:

(readonly) androidStockBrowserVersion :number

The Android version linked to the stock browser.
Type:
  • number
Source:

(readonly) applicationCache :boolean

Is Application Cache supported to enable web-based applications run offline?
Type:
  • boolean
Source:

(readonly) audioTag :boolean

Are Audio tags available?
Type:
  • boolean
Source:

(readonly) battery :boolean

Is the Battery API available?
Type:
  • boolean
Source:

(readonly) browser :string

The nick name of the browser.
Type:
  • string
Source:

(readonly) browserVersion :number

The browser major version.
Type:
  • number
Source:

(readonly) canvas :boolean

Is canvas available?
Type:
  • boolean
Source:

(readonly) canvasText :boolean

Is text API for canvas available?
Type:
  • boolean
Source:

(readonly) canvasWinding :boolean

Are winding rules for '' (go clockwise or counterclockwise) available?
Type:
  • boolean
Source:

(readonly) chrome :boolean

Is running in Chrome?
Type:
  • boolean
Source:

(readonly) chromeOS :boolean

Is running on chromeOS?
Type:
  • boolean
Source:

(readonly) chromeVersion :number

Chrome major version number.
Type:
  • number
Source:

(readonly) className :string

Get the class name of the object.
Type:
  • string
Inherited From:
Source:

(readonly) contextMenu :boolean

Is context menu available?
Type:
  • boolean
Source:

(readonly) css3D :boolean

Is css3D available?
Type:
  • boolean
Source:

(readonly) cssAnimation :boolean

Are css animations (keyframes) supported?
Type:
  • boolean
Source:

(readonly) cssPointerEvents :boolean

Is pointer-events available?
Type:
  • boolean
Source:

(readonly) cssRgba :boolean

Is rgba (alpha) available?
Type:
  • boolean
Source:

data :*

Get and set any custom data you want to associate to this object.
Type:
  • *
Inherited From:
Source:

debug :boolean

Get and set the debug flag.
Type:
  • boolean
Inherited From:
Source:

(readonly) desktop :boolean

Is running on a desktop?
Type:
  • boolean
Source:

(readonly) deviceMotion :boolean

Is Device Motion Event supported? (Accelerometer)
Type:
  • boolean
Source:

(readonly) deviceMotionAcceleration :boolean

Is Device Motion acceleration supported?
Type:
  • boolean
Source:

(readonly) deviceMotionRotationRate :boolean

Is Device Motion rotation supported?
Type:
  • boolean
Source:

(readonly) deviceOrientation :boolean

Is Device Orientation Event supported? (Magnetometer)
Type:
  • boolean
Source:

(readonly) deviceOrientationMagnetometer :boolean

Is Device Orientation motion supported?
Type:
  • boolean
Source:

(readonly) dpi :number

Pixel density of the screen.
Type:
  • number
Source:

(readonly) edge :boolean

Is running in Edge?
Type:
  • boolean
Source:

(readonly) edgeVersion :number

Edge major version number.
Type:
  • number
Source:

(readonly) encryptedMedia :boolean

Is Encrypted Media Extensions API available?
Type:
  • boolean
Source:

(readonly) exitFullscreen :string

Exit full screen method name.
Type:
  • string
Source:

(readonly) file :boolean

Is file available?
Type:
  • boolean
Source:

(readonly) fileSystem :boolean

Is fileSystem available?
Type:
  • boolean
Source:

(readonly) firefox :boolean

Is running in Firefox?
Type:
  • boolean
Source:

(readonly) firefoxVersion :number

Firefox major version number.
Type:
  • number
Source:

(readonly) fullscreenElement :string

fullscreenElement accessor name.
Type:
  • string
Source:

(readonly) fullscreenEnabled :string

Does the browser support full screen API?
Type:
  • string
Source:

(readonly) fullscreenKeyboard :boolean

Does the browser support keyboard during full screen mode?
Type:
  • boolean
Source:

(readonly) gamepad :boolean

Is Gamepad API available?
Type:
  • boolean
Source:

(readonly) geolocation :boolean

Is Geolocation API available?
Type:
  • boolean
Source:

(readonly) gyroscope :boolean

Device has a real gyroscope?
Type:
  • boolean
Source:

(readonly) h264Video :boolean

Can play h264 video files?
Type:
  • boolean
Source:

(readonly) history :boolean

Is History API available?
Type:
  • boolean
Source:

(readonly) hlsVideo :boolean

Can play hls video files?
Type:
  • boolean
Source:

(readonly) ie :boolean

Is running in Internet Explorer?
Type:
  • boolean
Source:

(readonly) ieVersion :number

Internet Explorer major version number.
Type:
  • number
Source:

(readonly) iOS :boolean

Is running on iOS?
Type:
  • boolean
Source:

(readonly) iPad :boolean

Is running on iPad?
Type:
  • boolean
Source:

(readonly) iPhone :boolean

Is running on iPhone?
Type:
  • boolean
Source:

(readonly) iPod :boolean

Is running on iPod?
Type:
  • boolean
Source:

(readonly) isAndroidStockBrowser :boolean

Detect if it's an Android Stock browser.
Type:
  • boolean
Source:

(readonly) isIframe :boolean

Is the current page is into an Iframe ?
Type:
  • boolean
Source:

(readonly) isSecure :boolean

Is the current page in secure mode?
Type:
  • boolean
Source:

(readonly) JSON :boolean

Is JSON native support available?
Type:
  • boolean
Source:

(readonly) kindle :boolean

Is running on Kindle?
Type:
  • boolean
Source:

(readonly) language :string

The browser language.
Type:
  • string
Source:

(readonly) linux :boolean

Is running on Linux?
Type:
  • boolean
Source:

(readonly) localStorage :boolean

Is localStorage available?
Type:
  • boolean
Source:

(readonly) lockOrientation :string

Lock screen orientation method name.
Type:
  • string
Source:

(readonly) m4a :boolean

Can play m4a files?
Type:
  • boolean
Source:

(readonly) macOS :boolean

Is running on MacOS?
Type:
  • boolean
Source:

(readonly) mediaSource :boolean

Is Media Source Extensions API available?
Type:
  • boolean
Source:

(readonly) mobile :boolean

Is running on a mobile?
Type:
  • boolean
Source:

(readonly) mp3 :boolean

Can play mp3 files?
Type:
  • boolean
Source:

(readonly) mp4 :boolean

Can play mp4 files?
Type:
  • boolean
Source:

(readonly) mp4Video :boolean

Can play mp4 video files?
Type:
  • boolean
Source:

(readonly) ogg :boolean

Can play ogg files?
Type:
  • boolean
Source:

(readonly) oggVideo :boolean

Can play ogg video files?
Type:
  • boolean
Source:

(readonly) onDestroy :FORGE.EventDispatcher

Get the onDestroy FORGE.EventDispatcher, this event is emitted at the end of the destroy sequence.
Type:
Inherited From:
Source:

(readonly) onReady :FORGE.EventDispatcher

Get the onReady EventDispatcher.
Type:
Source:

(readonly) opera :boolean

Is running in Opera?
Type:
  • boolean
Source:

(readonly) operaVersion :number

Opera major version number.
Type:
  • number
Source:

(readonly) opus :boolean

Can play opus files?
Type:
  • boolean
Source:

(readonly) orientation :string

Screen orientation object name.
Type:
  • string
Source:

(readonly) os :string

The OS name
Type:
  • string
Source:

(readonly) osVersion :number

The OS major version number.
Type:
  • number
Source:

(readonly) other :boolean

Is running on a other device as smartTv...?
Type:
  • boolean
Source:

(readonly) pixelRatio :number

Pixel ratio of the device.
Type:
  • number
Source:

(readonly) pointerLock :boolean

Is pointerLock available?
Type:
  • boolean
Source:

(readonly) quirksMode :boolean

Is the browser running in strict mode or quirks mode?
Type:
  • boolean
Source:

(readonly) ready :boolean

Is device detection done?
Type:
  • boolean
Source:

(readonly) requestFullscreen :string

Request full screen method name.
Type:
  • string
Source:

(readonly) retina :boolean

Is running on Apple Retina display?
Type:
  • boolean
Source:

(readonly) safari :boolean

Is running in Safari?
Type:
  • boolean
Source:

(readonly) safariVersion :number

Safari (or Mobile Safari) major version number.
Type:
  • number
Source:

(readonly) screenHeight :number

Device screen height in pixels.
Type:
  • number
Source:

(readonly) screenOrientation :boolean

Is screen orienation API available?
Type:
  • boolean
Source:

(readonly) screenWidth :number

Device screen width in pixels.
Type:
  • number
Source:

(readonly) silk :boolean

Is running in Silk (Kindle)?
Type:
  • boolean
Source:

(readonly) svg :boolean

Is SVG in '' or '' supported?
Type:
  • boolean
Source:

(readonly) tablet :boolean

Is running on a tablet?
Type:
  • boolean
Source:

(readonly) tags :Array

Get the tags associated to this object.
Type:
  • Array
Inherited From:
Source:

(readonly) touch :boolean

Is Touch API available?
Type:
  • boolean
Source:

(readonly) touchForce :boolean

Are Force Touch Events supported? Force Touch events are available in OS X 10.11 and later on devices equipped with Force Touch trackpads.
Type:
  • boolean
Source:

(readonly) ua :string

The user agent string.
Type:
  • string
Source:

(readonly) uid :string

Get the uid of the object.
Type:
  • string
Inherited From:
Source:

(readonly) unlockOrientation :string

Unlock screen orientation method name.
Type:
  • string
Source:

(readonly) vibrate :boolean

Does the device support the Vibration API?
Type:
  • boolean
Source:

(readonly) visibilityChange :string

Visibility change event name for the PageVisibility API.
Type:
  • string
Source:

(readonly) visibilityState :string

Hidden state name for the PageVisibility API.
Type:
  • string
Source:

(readonly) vita :boolean

Is running on PS Vita?
Type:
  • boolean
Source:

(readonly) vp9Video :boolean

Can play vp9 video files?
Type:
  • boolean
Source:

warning :boolean

Get and set the warning flag.
Type:
  • boolean
Inherited From:
Source:

(readonly) wav :boolean

Can play wav files?
Type:
  • boolean
Source:

(readonly) weba :boolean

Can play weba files?
Type:
  • boolean
Source:

(readonly) webApp :boolean

Is running in a standalone app?
Type:
  • boolean
Source:

(readonly) webAudio :boolean

Is the WebAudio API available?
Type:
  • boolean
Source:

(readonly) webGL :boolean

Is webGL available?
Type:
  • boolean
Source:

(readonly) webm :boolean

Can play webm files?
Type:
  • boolean
Source:

(readonly) webmVideo :boolean

Can play webm video files?
Type:
  • boolean
Source:

(readonly) webVR :boolean

Is WebVR available?
Type:
  • boolean
Source:

(readonly) windows :boolean

Is running on Windows?
Type:
  • boolean
Source:

(readonly) windowsPhone :boolean

Is running on Windows Phone?
Type:
  • boolean
Source:

(readonly) xbox :boolean

Is running on XBox?
Type:
  • boolean
Source:

Methods

canPlayAudio(type) → {boolean}

Check if the device can play audio.
Parameters:
Name Type Description
type string One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
Source:
Returns:
Type
boolean

canPlayVideo(type) → {boolean}

Check If the device can play video files.
Parameters:
Name Type Description
type string One of 'mp4, 'ogg', 'webm' or 'mpeg'.
Source:
Returns:
Type
boolean

check(config) → {boolean}

Check device requirement for an object from configuration/manifest.
Parameters:
Name Type Description
config Object The device requirement configuration of the configuration/manifest.
Source:
Returns:
Returns true if the object is compatible with the device environment, false if not.
Type
boolean

destroy()

Basic destroy method, prevent double destroy, change the alive flag.
Inherited From:
Source:

isLowBattery() → {Promise.<boolean>}

Check If the battery is low.
Note "low" is defined as less than 20%.
Source:
Returns:
Type
Promise.<boolean>

log(value)

Basic log method, log a string in the console if debug is enabled.
Parameters:
Name Type Description
value * The value you want to log in the console.
Inherited From:
Source:

warn(valuenullable)

Basic warn method, log a warn string in the console if warning is enabled.
Parameters:
Name Type Attributes Description
value string | Object <nullable>
The value you want to warn in the console.
Inherited From:
Source: