Class: Player

player/Player.Player(viewport, presentation, editModeopt)

Sozi presentation player.

Constructor

new Player(viewport, presentation, editModeopt)

Initialize a new Sozi player.

If the presentation is opened in edit mode, the player will disable these features:

  • mouse and keyboard actions for navigating in the presentation,
  • automatic transitions after a timeout.
Parameters:
Name Type Attributes Default Description
viewport module:player/Viewport.Viewport

The viewport where the presentation is rendered.

presentation module:model/Presentation.Presentation

The presentation to play.

editMode boolean <optional>
false

Is the presentation opened in edit mode?

Source:

Extends

  • EventEmitter

Members

animator :module:player/Animator.Animator

An animator to control the transitions.

Type:
Source:

(readonly) blankScreenIsVisible :boolean

Is the blank screen activated?

Type:
  • boolean
Source:

currentFrame :module:model/Presentation.Frame

The current frame of the presentation.

Type:
Source:

editMode :boolean

Is the presentation opened in edit mode?

Type:
  • boolean
Default Value:
  • false
Source:

(readonly) nextFrame :module:model/Presentation.Frame

The frame after the current frame.

If a transition is in progress, returns the frame after the target frame. When reaching the last frame, cycle to the first of the presentation.

Type:
Source:

playing :boolean

The playing/paused state of this player.

Type:
  • boolean
Source:

presentation :module:model/Presentation.Presentation

The presentation to play.

Type:
Source:

(readonly) previousFrame :module:model/Presentation.Frame

The frame before the current frame.

If a transition is in progress, returns the frame before the target frame. When reaching the first frame, cycle to the last of the presentation.

Type:
Source:

targetFrame :module:model/Presentation.Frame

The target frame of the current transition.

Type:
Source:

(nullable) timeoutHandle :number

The result of setTimeout when starting waiting for a frame timeout.

Type:
  • number
Source:

transitions :Array.<object>

An array of tansition descriptors for each camera.

Type:
  • Array.<object>
Default Value:
  • []
Source:
See:

viewport :module:player/Viewport.Viewport

The viewport where the presentation is rendered.

Type:
Source:

waitingTimeout :boolean

Is the player waiting for a frame timeout to complete?

Type:
  • boolean
Source:

Methods

disableBlankScreen()

Disable the blank screen.

This method will reveal the viewport again.

Source:

disableMedia()

Disable all video and audio elements in the current presentation.

Source:

enableBlankScreen()

Enable the blank screen.

This method will pause the presentation and hide the viewport under an opaque element.

Source:

findFrame(frame) → (nullable) {module:model/Presentation.Frame}

Find a frame by its ID or number.

Parameters:
Name Type Description
frame string | number | module:model/Presentation.Frame

An indication of the frame to find.

Source:
Returns:
  • The frame found, or null.
Type
module:model/Presentation.Frame

jumpToFirst()

Jumps to the first frame of the presentation.

Source:
Fires:

jumpToFrame(frame)

Jump to a frame.

This method does not animate the transition from the current state of the viewport to the desired frame.

The presentation is stopped: if a timeout has been set for the target frame, it will be ignored.

Parameters:
Name Type Description
frame string | number | module:model/Presentation.Frame

The frame to show.

Source:
Fires:

jumpToLast()

Jump to the last frame of the presentation.

Source:
Fires:

jumpToNext()

Jumps to the next frame.

Source:
Fires:

jumpToPrevious()

Jump to the previous frame.

Source:
Fires:

moveToCurrent()

Restore the current frame.

This method restores the viewport to fit the current frame, e.g. after the viewport has been zoomed or dragged.

Source:
Fires:

moveToFirst()

Move to the first frame of the presentation.

Source:
Fires:

moveToFrame(frame)

Move to a frame.

This method animates the transition from the current state of the viewport to the desired frame.

If the given frame corresponds to the next frame in the list, the transition properties of the next frame are used. Otherwise, default transition properties are used.

Parameters:
Name Type Description
frame string | number | module:model/Presentation.Frame

The first frame to show.

Source:
Fires:

moveToLast()

Move to the last frame of the presentation.

Source:
Fires:

moveToNext()

Move to the next frame.

Source:
Fires:

moveToPrevious()

Move to the previous frame.

This method skips previous frames with 0 ms timeout.

Source:
Fires:

onAnimatorDone()

Finalize a transition when the current animation is complete.

If the presentation is in playing state, wait for the current frame's timeout.

Source:
Fires:
Listens to Events:

onAnimatorStep(progress)

Process an animation step.

This method moves each camera according to the list of transition descriptors.

Parameters:
Name Type Description
progress number

The relative time already elapsed between the initial and final states of the current animation (between 0 and 1).

Source:
See:
  • module:player/Player.Camera#interpolate
Listens to Events:

onAnimatorStop()

Finalize a transition when the current animation is stopped.

This method clears the list of transition descriptors.

Source:
Fires:
Listens to Events:

onClick(button)

Move to the next or previous frame on each click event in the viewport.

This method is registered as a click event handler of the current viewport.

Parameters:
Name Type Description
button number

The index of the button that was pressed.

Source:
Listens to Events:

onKeyDown(evt)

Process a keyboard event.

This method handles the navigation keys if they are enabled in the current presentation: Arrows, Page-Up/Down, Home, End, Enter, and Space.

Parameters:
Name Type Description
evt KeyboardEvent

The DOM event to process.

Source:
Listens to Events:
  • event:keydown

onKeyPress(evt)

Process a keyboard event.

This method handles character keys: "+", "-", "R", "P", ".".

Parameters:
Name Type Description
evt KeyboardEvent

The DOM event to process.

Source:
Listens to Events:
  • event:keypress

pause()

Pause the presentation.

This method clears the playing flag. If the presentation was in "waiting" mode due to a timeout in the current frame, then it stops waiting. The current animation is stopped in its current state.

Source:
Fires:
Listens to Events:

playFromFrame(frame)

Start the presentation from the given frame.

This method sets the playing flag, shows the desired frame and waits for the frame timeout if needed.

Parameters:
Name Type Description
frame string | number | module:model/Presentation.Frame

The first frame to show.

Source:
Fires:

previewFrame(frame)

Move to a frame in preview mode.

This method animates the transition from the current state of the viewport to the desired frame, using default transition settings.

Parameters:
Name Type Description
frame string | number | module:model/Presentation.Frame

The first frame to show.

Source:
Fires:

resume()

Resume playing from the current frame.

Source:

setupTransition(camera, timingFunction, relativeZoom, svgPath, backwardsopt)

Prepare a transition for a given camera.

The initial state is the current state of the given camera. The final state is the camera state in the current layer of the target frame.

A new descriptor is added to the list of transition descriptors.

Parameters:
Name Type Attributes Default Description
camera module:player/Camera.Camera

The camera that will perform the transition.

timingFunction string

The name of function that maps the progress indicator to the relative distance already completed between the initial and final states (between 0 and 1).

relativeZoom number

An additional zooming factor to apply during the transition.

svgPath SVGPathElement

An SVG path to follow during the transition.

backwards boolean <optional>
false

If true, apply the reverse timing function and follow the transition path in the opposite direction.

Source:

showCurrentFrame()

Force the viewport to show the current frame.

This method will set all cameras to the states in the current frame, and update the viewport.

Source:
Fires:

toggleBlankScreen()

Toggle the visibility of the elements that hides the viewport.

Source:

waitTimeout()

Starts waiting before moving to the next frame.

If the current frame has a timeout set, this method will register a timer to move to the next frame automatically after the specified time.

If the current frame is the last, the presentation will move to the first frame.

Source: