Player Reference

class Player()

The Player object handles initializing the player, holds state, and handles events for updating state.

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.

Player.determineCurrentQuadrant()

PiP Corner Snapping Helper Function Determines the quadrant the PiP window is currently in.

Player.determineDirectionDragged()

Uses the PiP window’s change in position to determine which direction the window has been moved in.

Player.init(id, wgp, videoRef)

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

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.lastScreenX

Used for window movement Telemetry to determine if the player window has moved since the last time we checked.

Player.moveToBottomLeft()

Moves the PiP window to the bottom left.

Player.moveToBottomRight()

Moves the PiP window to the bottom right.

Player.moveToTopLeft()

Moves the PiP window to the top left.

Player.moveToTopRight()

Helper function to actually move/snap the PiP window. Moves the PiP window to the top right.

Player.oldMouseUpWindowX

Used to determine old window location when mouseup-ed for corner snapping drag vector calculation

Player.onCommand(event)

Event handler for user issued commands

Arguments
  • event (Event()) – Event context data object

Player.onMouseMove()

Event handler for mousemove the PiP Window

Player.onMouseUp(event)

Event handler for “mouseup” events on the PiP window.

Arguments
  • event (Event()) – Event context details

Player.onResize(event)

Event handler for resizing the PiP Window

Arguments
  • event (Event()) – Event context data object

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.

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.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.

Player.showingTimeout

When set to a non-null value, a timer is scheduled to hide the controls after CONTROLS_FADE_TIMEOUT_MS milliseconds.