Constructor
new Controls(playernon-null, videoContainernon-null, videonon-null, vrCanvasnullable, config)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
player |
shaka.Player | ||
videoContainer |
HTMLElement | ||
video |
HTMLMediaElement | ||
vrCanvas |
HTMLCanvasElement |
<nullable> |
|
config |
shaka.extern.UIConfiguration |
- Implements:
- Source:
Members
fadeControlsTimer_ :shaka.util.Timer
This timer is used to delay the fading of the UI.
Type:
- Source:
hideSettingsMenusTimer_ :shaka.util.Timer
This timer will be used to hide all settings menus. When the timer ticks
it will force all controls to invisible.
Rather than calling the callback directly, |Controls| will always call it
through the timer to avoid conflicts.
Type:
- Source:
mouseStillTimer_ :shaka.util.Timer
This timer is used to detect when the user has stopped moving the mouse
and we should fade out the ui.
Type:
- Source:
pressedKeys_ :Set.<string>
The pressed keys set is used to record which keys are currently pressed
down, so we can know what keys are pressed at the same time.
Used by the focusInsideOverflowMenu_() function.
Type:
- Set.<string>
- Source:
showOnHoverControls_ :Array.<!Element>
Individual controls which, when hovered or tab-focused, will force the
controls to be shown.
Type:
- Array.<!Element>
- Source:
timeAndSeekRangeTimer_ :shaka.util.Timer
This timer is used to regularly update the time and seek range elements
so that we are communicating the current state as accurately as possibly.
Unlike the other timers, this timer does not "own" the callback because
this timer is acting like a heartbeat.
Type:
- Source:
Methods
createLocalization_() → {shaka.ui.Localization}
Create a localization instance already pre-loaded with all the locales that
we support.
- Source:
Returns:
registerElement(name, factorynon-null)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
factory |
shaka.extern.IUIElement.Factory |
- Source:
registerSeekBar(factorynon-null)
Parameters:
Name | Type | Description |
---|---|---|
factory |
shaka.extern.IUISeekBar.Factory |
- Source:
addAdControls_()
- Source:
addBufferingSpinner_()
- Source:
addClientAdContainer_()
Adds a container for client side ad UI with IMA SDK.
- Source:
addContextMenu_()
- Source:
addControlsButtonPanel_()
- Source:
addControlsContainer_()
- Source:
addDaiAdContainer_()
Adds a container for server side ad UI with IMA SDK.
- Source:
addEventListeners_()
Adds static event listeners. This should only add event listeners to
things that don't change (e.g. Player). Dynamic elements (e.g. controls)
should have their event listeners added when they are created.
- Source:
addFastForwardButtonOnControlsContainer_()
Add fast-forward button on Controls container for moving video some
seconds ahead when the video is tapped more than once, video seeks ahead
some seconds for every extra tap.
- Source:
addPlayButton_()
- Source:
addRewindButtonOnControlsContainer_()
Add Rewind button on Controls container for moving video some seconds
behind when the video is tapped more than once, video seeks behind some
seconds for every extra tap.
- Source:
addScrimContainer_()
- Source:
addSeekBar_()
Adds a seekbar depending on the configuration.
By default an instance of shaka.ui.SeekBar is created
This behaviour can be overriden by providing a SeekBar factory using the
registerSeekBarFactory function.
- Source:
allowCast(allow)
This allows the application to inhibit casting.
Parameters:
Name | Type | Description |
---|---|---|
allow |
boolean |
- Source:
canPlayVR() → {boolean}
Returns if a VR is capable.
- Source:
Returns:
- Type
- boolean
computeOpacity()
Recompute whether the controls should be shown or hidden.
- Source:
configure(confignon-null)
Parameters:
Name | Type | Description |
---|---|---|
config |
shaka.extern.UIConfiguration |
- Source:
copyStyleSheetsToWindow_()
- Source:
createDOM_()
- Source:
destroy() → {Promise}
Request that this object be destroyed, releasing all resources and shutting
down all operations. Returns a Promise which is resolved when destruction
is complete. This Promise should never be rejected.
- Implements:
- Source:
Returns:
- Type
- Promise
enterFullScreen_()
- Source:
exitFullScreen_()
- Source:
getClientSideAdContainer() → {HTMLElement}
- Source:
Returns:
- Type
- HTMLElement
getServerSideAdContainer() → {HTMLElement}
- Source:
Returns:
- Type
- HTMLElement
getVRFieldOfView() → {number}
Returns the angle of the current field of view displayed in degrees.
- Source:
Returns:
- Type
- number
getVRNorth() → {number}
Get the angle of the north.
- Source:
Returns:
- Type
- number
hideAdUI()
- Source:
hideSettingsMenus()
- Source:
hideUI()
- Source:
incrementPitch(angle)
Increment the pitch in X angle in degrees.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | In degrees |
- Source:
incrementRoll(angle)
Increment the roll in X angle in degrees.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | In degrees |
- Source:
incrementYaw(angle)
Increment the yaw in X angle in degrees.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | In degrees |
- Source:
isHovered_() → {boolean}
- Source:
Returns:
true if any relevant elements are hovered.
- 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
keepFocusInMenu_(eventnon-null)
When the user is using keyboard to navigate inside the overflow settings
menu (pressing Tab key to go forward, or pressing Shift + Tab keys to go
backward), make sure it's focused only on the elements of the overflow
panel.
This is called by onWindowKeyDown_() function, when there's a settings
overflow menu open, and the Tab key / Shift+Tab keys are pressed.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event |
- Source:
loadComplete()
Used by the application to notify the controls that a load operation is
complete. This allows the controls to recalculate play/paused state, which
is important for platforms like Android where autoplay is disabled.
- Source:
onBufferingStateChange_()
Called both as an event listener and directly by the controls to initialize
the buffering state.
- Source:
onCastStatusChange_()
- Source:
onContainerClick_()
- Source:
onContainerTouch_(eventnon-null)
Parameters:
Name | Type | Description |
---|---|---|
event |
Event |
- Source:
onControlsKeyDown_(eventnon-null)
Support controls with keyboard inputs.
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent |
- Source:
onControlsKeyUp_(eventnon-null)
Support controls with keyboard inputs.
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent |
- Source:
onMouseDown_()
For keyboard navigation, we use blue borders to highlight the active
element. If we detect that a mouse is being used, remove the blue border
from the active element.
- Source:
onMouseLeave_()
- Source:
onMouseMove_(eventnon-null)
Hiding the cursor when the mouse stops moving seems to be the only
decent UX in fullscreen mode. Since we can't use pure CSS for that,
we use events both in and out of fullscreen mode.
Showing the control bar when a key is pressed, and hiding it after some
time.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event |
- Source:
onMouseStill_()
This callback is for when we are pretty sure that the mouse has stopped
moving (aka the mouse is still). This method should only be called via
|mouseStillTimer_|. If this behaviour needs to be invoked directly, use
|mouseStillTimer_.tickNow()|.
- Source:
onPlayPauseClick_()
- Source:
onPlayStateChange_()
- Source:
onScreenRotation_()
When a mobile device is rotated to landscape layout, and the video is
loaded, make the demo app go into fullscreen.
Similarly, exit fullscreen when the device is rotated to portrait layout.
- Source:
onWindowKeyDown_(eventnon-null)
Add behaviors for keyboard navigation.
1. Add blue outline for focused elements.
2. Allow exiting overflow settings menus by pressing Esc key.
3. When navigating on overflow settings menu by pressing Tab
key or Shift+Tab keys keep the focus inside overflow menu.
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent |
- Source:
presentationIsPaused() → {boolean}
Return true if the presentation is paused.
- Source:
Returns:
- Type
- boolean
releaseChildElements_()
- Source:
removeMediaSession_()
- Source:
seek_(currentTime)
Update the video's current time based on the keyboard operations.
Parameters:
Name | Type | Description |
---|---|---|
currentTime |
number |
- Source:
setEnabledNativeControls(enabled)
Enable or disable native browser controls. Enabling disables shaka
controls.
Parameters:
Name | Type | Description |
---|---|---|
enabled |
boolean |
- Source:
setEnabledShakaControls(enabled)
Enable or disable the custom controls. Enabling disables native
browser controls.
Parameters:
Name | Type | Description |
---|---|---|
enabled |
boolean |
- Source:
setLastTouchEventTime(timenullable)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
time |
number |
<nullable> |
- Source:
setSeeking(seeking)
Parameters:
Name | Type | Description |
---|---|---|
seeking |
boolean |
- Source:
setupMediaSession_()
- Source:
setVRFieldOfView(fieldOfView)
Changing the field of view increases or decreases the portion of the video
that is viewed at one time. If the field of view is decreased, a small
part of the video will be seen, but with more detail. If the field of view
is increased, a larger part of the video will be seen, but with less
detail.
Parameters:
Name | Type | Description |
---|---|---|
fieldOfView |
number | In degrees |
- Source:
showAdUI()
- Source:
showUI()
- Source:
toggleDocumentPictureInPicture_()
The Document Picture-in-Picture API makes it possible to open an
always-on-top window that can be populated with arbitrary HTML content.
https://developer.chrome.com/docs/web-platform/document-picture-in-picture
- Source:
toggleFullScreen()
- Source:
togglePiP()
- Source:
updateTimeAndSeekRange_()
Called when the seek range or current time need to be updated.
- Source:
Events
CaptionSelectionUpdatedEvent
Fired when the captions/subtitles menu has finished updating.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'captionselectionupdated' |
- Source:
CastStatusChangedEvent
Fired upon receiving a 'caststatuschanged' event from
the cast proxy.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'caststatuschanged' |
newStatus |
boolean | The new status of the application. True for 'is casting' and false otherwise. |
- Source:
ErrorEvent
Fired when something went wrong with the controls.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'error' |
detail |
shaka.util.Error | An object which contains details on the error. The error's 'category' and 'code' properties will identify the specific error that occurred. In an uncompiled build, you can also use the 'message' and 'stack' properties to debug. |
- Source:
LanguageSelectionUpdatedEvent
Fired when the audio language menu has finished updating.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'languageselectionupdated' |
- Source:
ResolutionSelectionUpdatedEvent
Fired when the resolution menu has finished updating.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'resolutionselectionupdated' |
- Source:
SubMenuOpenEvent
Fired when one of the overflow submenus is opened
(e. g. language/resolution/subtitle selection).
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'submenuopen' |
- Source:
TimeAndSeekRangeUpdatedEvent
Fired when the time and seek range elements have finished
updating.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'timeandseekrangeupdated' |
- Source:
UIUpdatedEvent
Fired after a call to ui.configure() once the UI has finished
updating.
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'uiupdated' |
- Source:
VRStatusChangedEvent
Fired when VR status change
Properties:
Name | Type | Description |
---|---|---|
type |
string | 'vrstatuschanged' |
- Source: