- Version
- 1.0.0
- License
- MIT
- Requires
- DomSmith
- Looper
- convertTime
- Source
- Time.js, line 17
Constructor
new Time(player, parent)
Creates an instance of the Time component.
| Name | Type | Description |
|---|---|---|
player |
Player |
Reference to the Visi#onPlayer instance. |
parent |
Controller |
The parent container, in this case the controller. |
Members
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
display
|
string | optional | "current" | Initial time display mode, either "current" or "remaining". |
showFrames
|
boolean | optional | false | Whether to display frames in the time string. |
private #player :Player
private #dom :DomSmith
private #renderLoop :Looper
Methods
private #onMediaReady()
Sets up the component as soon as the media is available. Uses a placeholder text if the stream is a Live Stream.
- Listens
- media/ready
- Source
- Time.js, line 111
private #onPlay()
Immediately updates time display when playback starts (and frames are shown).
- Listens
- media/play
- Source
- Time.js, line 149
private #onPause()
Cancels frame-based updates when paused.
- Listens
- media/pause
- Source
- Time.js, line 159
private #onTimeUpdate()
Updates the time display based on the timeupdate event, or by using a requestAnimationFrame if frames should be displayed as well (to get more smooth updates in this case).
- Listens
- media/timeupdate
- Source
- Time.js, line 170
private #onToggleTime()
Toggles time display mode between "current" and "remaining" after user klicked on the time display.
private #enable()
Enables the play time display. This method listens to canplay events in order to restore a usable state again when the player recovered from a media error (for example by loading another file).
- Listens
- media/canplay
- Source
- Time.js, line 220
private #disable()
Disables the time display. This method listens to media error events which cause the time display to be disabled.
- Listens
- media/error
- data/nomedia
- Source
- Time.js, line 231