Constructor
new VRManager(containernon-null, canvasnullable, videonon-null, playernon-null, config, controlsnon-null)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
container |
HTMLElement | ||
canvas |
HTMLCanvasElement |
<nullable> |
|
video |
HTMLMediaElement | ||
player |
shaka.Player | ||
config |
shaka.extern.UIConfiguration | ||
controls |
shaka.ui.Controls |
- Implements:
- Source:
Members
CLICK_MAX_DISTANCE_ :number
How far a pointer can move during a click on the video, in pixels. Past
that, the gesture moves the view instead.
Type:
- number
- Source:
DOUBLE_CLICK_TIME_ :number
How long after moving the view a double click is still ignored, in ms. It
covers the time between the two clicks of most double clicks.
Type:
- number
- Source:
DRAG_SPEED_ :number
How far a drag turns the view, in fields of view per pixel: 0.6 degrees
per pixel at the default field of view of 75 degrees.
Type:
- number
- Source:
INERTIA_MIN_SPEED_ :number
The speed at which the view stops after a drag, in radians per
millisecond (about 1 degree per second).
Type:
- number
- Source:
INERTIA_SAMPLE_TIME_ :number
The time before the release of a drag that gives the speed of the view,
in milliseconds.
Type:
- number
- Source:
INERTIA_TIME_CONSTANT_ :number
How fast the view slows down after a drag: its speed is divided by e every
this many milliseconds.
Type:
- number
- Source:
KEYBOARD_LOOK_SPEED_ :number
How fast the keyboard turns the view, in fields of view per second.
Type:
- number
- Source:
KEYBOARD_ZOOM_STEP_ :number
How much a key press zooms, in degrees of field of view.
Type:
- number
- Source:
PINCH_ZOOM_FACTOR_ :number
Amount of field of view change per pixel of pinch distance change.
The value is scaled down by 50 in shaka.ui.VRWebgl.zoom, so this results
in 0.1 degrees of field of view per pixel.
Type:
- number
- Source:
gestureMovedView_ :boolean
True if the last gesture moved the view, so that the click that ends it
does not play or pause the video.
Type:
- boolean
- Source:
inertia_ :Array<number>
The speed of the view after a drag, in radians per millisecond, as
[yaw, pitch].
Type:
- Array<number>
- Source:
lastMovingGestureTime_ :number
When the last gesture that moved the view ended, in milliseconds.
Type:
- number
- Source:
lookDirections_ :Map<string, !Array<number>>
The direction of each key that turns the view while it is held, as
[yaw, pitch].
Type:
- Map<string, !Array<number>>
- Source:
lookEventManager_ :shaka.util.EventManager
Listens to the release of the keys anywhere, so that the view does not
keep turning when the focus moves while a key is held.
Type:
- Source:
pointers_ :Map<number, {x: number, y: number, startX: number, startY: number}>
The position of the active pointers, and where they went down, by
pointer id.
Type:
- Map<number, {x: number, y: number, startX: number, startY: number}>
- Source:
recentMoves_ :Array<{time: number, yaw: number, pitch: number}>
The last moves of the drag, to measure the speed of the view when the
pointer is released.
Type:
- Array<{time: number, yaw: number, pitch: number}>
- Source:
vrStereoLayout_ :shaka.ui.VRWebgl.StereoLayout
The stereo layout signaled in the content, if any.
Type:
- Source:
Methods
getScreenOrientationAngle_() → {number}
Returns the rotation of the screen, normalized to 0, 90, 180 or 270
degrees.
- Source:
Returns:
- Type
- number
now_() → {number}
- Source:
Returns:
The current time, in milliseconds.
- Type
- number
toStereoLayout_(stereoLayoutnullable) → {shaka.ui.VRWebgl.StereoLayout}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
stereoLayout |
string |
<nullable> |
As signaled in the content or the configuration. |
- Source:
Returns:
How to display it, or null if
it is unknown.
canPlayVR() → {boolean}
Returns if a VR is capable.
- Source:
Returns:
- Type
- boolean
canStartGesture_(targetnullable) → {boolean}
Returns true if a VR gesture can start on this element. Gestures that
start on the controls (buttons, menus, seek bar) should not move the
view.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
target |
EventTarget |
<nullable> |
- Source:
Returns:
- Type
- boolean
checkVrStatus_()
- Source:
configure(confignon-null)
Parameters:
| Name | Type | Description |
|---|---|---|
config |
shaka.extern.UIConfiguration |
- Source:
dispatchStereoscopicModeChanged_()
- Source:
gestureMove_(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | |
y |
number |
- Source:
gestureStart_(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | |
y |
number |
- Source:
getFieldOfView() → {number}
Returns the field of view.
- Source:
Returns:
- Type
- number
getGL_(canvasnullable) → {WebGLRenderingContext}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
canvas |
HTMLCanvasElement |
<nullable> |
- Source:
Returns:
- Type
- WebGLRenderingContext
getLookSpeed_() → {Array<number>}
- Source:
Returns:
The speed of the view in the directions that are
held, in radians per millisecond, as [yaw, pitch].
- Type
- Array<number>
getNorth() → {number}
Get the angle of the north, which is the direction of the initial view.
- Source:
Returns:
In degrees, from 0 to 360, increasing as the view turns
to the right.
- Type
- number
getPinchDistance_() → {number}
- Source:
Returns:
The distance between the first two active pointers.
- Type
- number
getStereoLayout_() → {shaka.ui.VRWebgl.StereoLayout}
The layout signaled in the content takes precedence over the one in the
configuration.
- Source:
Returns:
incrementPitch(angle)
Increment the pitch in X angle in degrees.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
number |
- Source:
incrementRoll(angle)
Increment the roll in X angle in degrees.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
number |
- Source:
incrementYaw(angle)
Increment the yaw in X angle in degrees.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
number |
- Source:
inertiaStep_(time)
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number |
- Source:
init_(projectionMode, hfov)
Parameters:
| Name | Type | Description |
|---|---|---|
projectionMode |
string | |
hfov |
number |
- Source:
isClickFromGesture() → {boolean}
Tells if the click that ends the last gesture comes from moving the view,
by dragging, pinching or stopping it, instead of a click on the video.
- Source:
Returns:
- Type
- boolean
isDoubleClickFromGesture() → {boolean}
Tells if any of the clicks of a double click comes from moving the view.
- Source:
Returns:
- Type
- boolean
isPlayingVR() → {boolean}
Returns if a VR is supported.
- Source:
Returns:
- Type
- boolean
isStereoscopicModeEnabled() → {boolean}
Returns true if stereoscopic mode is enabled.
- Source:
Returns:
- Type
- boolean
listenToContextLoss_()
The browser can lose the WebGL context at any time, for example when the
GPU is reset or when a mobile browser reclaims its resources. Prevent
the default action of the event, so that the context can be restored,
and recreate the WebGL resources when it is.
- Source:
release()
Request that this object release all internal references.
- Implements:
- Source:
setFieldOfView(fieldOfView)
Set the field of view.
Parameters:
| Name | Type | Description |
|---|---|---|
fieldOfView |
number |
- Source:
setupDeviceOrientationListener_()
- Source:
setupGestureListeners_()
Pointer Events handle the mouse, touch and pen in the same way. The
pointer is captured by the container, so a drag keeps moving the view
after the pointer leaves it.
- Source:
setupVRListeners_()
- Source:
startInertia_()
Keeps the view moving after a drag, at the speed of its last moves, and
slows it down until it stops.
- Source:
startLooking(key, yaw, pitch)
Starts turning the view while a key or a button is held. Several of them
can be held at the same time, for example to look up and to the right.
The view stops turning when the key is released, or when stopLooking() is
called with the same id.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | The key, or the id of the button. |
yaw |
number | 1 to look to the right, -1 to the left. |
pitch |
number | 1 to look up, -1 down. |
- Source:
stopGestures_()
Stops listening to the gestures and to the device motion.
- Source:
stopInertia_()
- Source:
stopLooking(key)
Stops turning the view in the direction started by startLooking() with
the same id. Once no direction is held, the view keeps moving for a
moment and slows down, as after a drag.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | The key, or the id of the button. |
- Source:
stopLooking_()
- Source:
updateGesture_()
Starts the gesture that matches the active pointers: one pointer pans the
view, and two pointers pinch to zoom.
- Source:
zoomStep(direction)
Zooms in or out by a step.
Parameters:
| Name | Type | Description |
|---|---|---|
direction |
number | 1 to zoom in, -1 to zoom out. |
- Source: