Player Reference
- class Player()
The Player object handles initializing the player, holds state, and handles events for updating state.
- Player.deferredResize
Store the size and position of the window before entering fullscreen and use this to correctly position the window when exiting fullscreen
- Player.id
Used for Telemetry to identify the window.
- Player.isCurrentHover
Used to determine if hovering the mouse cursor over the pip window or not. Gets updated whenever a new hover state is detected.
- Player.isFullscreen
GET isFullscreen returns true if the video is running in fullscreen mode
- Player.isMuted
type: Boolean
GET isMuted returns true if the video is currently muted.
SET isMuted to true if the video is muted, false otherwise. This will update the internal state and displayed controls.
- Player.isPlaying
type: Boolean
GET isPlaying returns true if the video is currently playing.
SET isPlaying to true if the video is playing, false otherwise. This will update the internal state and displayed controls.
- Player.oldMouseUpWindowX
Used to determine old window location when mouseup-ed for corner snapping drag vector calculation
- Player.resizeDebouncer
Used for resizing Telemetry to avoid recording an event for every resize event. Instead, we wait until RESIZE_DEBOUNCE_RATE_MS has passed since the last resize event before recording.
- Player.showingTimeout
When set to a non-null value, a timer is scheduled to hide the controls after CONTROLS_FADE_TIMEOUT_MS milliseconds.
- static Player.alignEndControlsButtonTooltips()
Sets focus state inline end tooltip for rightmost playback controls
- static Player.computeAndSetMinimumSize(width, height)
Given a width and height for a video, computes the minimum dimensions for the player window, and then sets them on the root element.
This is currently only used on Linux GTK, where the OS doesn’t already impose a minimum window size. For other platforms, this function is a no-op.
- Arguments:
width (Number) – The width of the video being played.
height (Number) – The height of the video being played.
- static Player.determineCurrentQuadrant()
PiP Corner Snapping Helper Function Determines the quadrant the PiP window is currently in.
- static Player.determineDirectionDragged()
Uses the PiP window’s change in position to determine which direction the window has been moved in.
- static Player.handleAudioScrubbing(volume)
Set the volume on the video and unmute if the video was muted. If the volume is changed via the keyboard, onKeyDown will set this.preventNextInputEvent to true.
- Arguments:
volume (Number) – A number between 0 and 1 that represents the volume
- static Player.handleScrubbing(event)
This function handles when the scrubber is being scrubbed by the mouse because if we get an input event from the keyboard, onKeyDown will set this.preventNextInputEvent to true. This function is called by input events on the scrubber
- Arguments:
event (Event) – The input event
- static Player.handleScrubbingDone(event)
This function handles setting the scrubbing state to false and playing the video if we paused it before scrubbing.
- Arguments:
event (Event) – The change event
- static Player.hideVideoControls()
Send a message to PiPChild to adjust the subtitles position so that subtitles take up remaining space when hiding video controls.
- static Player.init(id, wgp, videoRef, autoFocus)
Initializes the player browser, and sets up the initial state.
- Arguments:
id (Number) – A unique numeric ID for the window, used for Telemetry Events.
wgp (WindowGlobalParent) – The WindowGlobalParent that is hosting the originating video.
videoRef (ContentDOMReference) – A reference to the video element that a Picture-in-Picture window is being created for
autoFocus (boolean) – Autofocus the PiP window
- static Player.moveToBottomLeft()
Moves the PiP window to the bottom left.
- static Player.moveToBottomRight()
Moves the PiP window to the bottom right.
- static Player.moveToTopLeft()
Moves the PiP window to the top left.
- static Player.moveToTopRight()
Helper function to actually move/snap the PiP window. Moves the PiP window to the top right.
- static Player.onCommand(event)
Event handler for user issued commands
- Arguments:
event (Event) – Event context data object
- static Player.onMouseMove()
Event handler for mousemove the PiP Window
- static Player.onMouseUp(event)
Event handler for “mouseup” events on the PiP window.
- Arguments:
event (Event) – Event context details
- static Player.onResize(event)
Event handler for resizing the PiP Window
- Arguments:
event (Event) – Event context data object
- static Player.recordEvent(type, args)
Used for recording telemetry in Picture-in-Picture.
- Arguments:
type (string) – The type of PiP event being recorded.
args (object) – The data to pass to telemetry when the event is recorded.
- static Player.revealControls(revealIndefinitely)
Makes the player controls visible.
- Arguments:
revealIndefinitely (Boolean) – If false, this will hide the controls again after CONTROLS_FADE_TIMEOUT_MS milliseconds has passed. If true, the controls will remain visible until revealControls is called again with revealIndefinitely set to false.
- static Player.showVideoControls()
Send a message to PiPChild to adjust the subtitles position so that subtitles are visible when showing video controls.
- static Player.toggleMute()
Toggle the mute state of the video
- static Player.toggleSubtitlesSettingsPanel(options)
Function to toggle the visibility of the subtitles settings panel
- Arguments:
options (Object) – [optional] Object containing options for the function - forceHide: true to force hide the subtitles settings panel - isKeyboard: true if the subtitles button was activated using the keyboard to show or hide the subtitles settings panel