TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/TextAliveJp/textalive-app-api/llms.txt
Use this file to discover all available pages before exploring further.
Timer interface defines the contract between the Player and an audio backend. The Player calls Timer methods to control playback and reads position to drive time-synchronized rendering. You can pass any Timer implementation to PlayerOptions.timer when constructing a Player.
Default timer behavior
When you do not specify atimer in PlayerOptions, the Player selects a timer automatically:
- If
songle-apiis available, aSongleTimer-based timer is used (audio playback via Songle). - Otherwise, a basic HTML5 audio timer is used.
Timer interface
Properties
Read-only.
true while the audio source is actively playing.Read-only. The current playback position in milliseconds. Timer implementations must calculate this value in real time. This is the most precise position value available — more accurate than
IPlayer.mediaPosition or IPlayer.videoPosition.Get or set the interval between position updates in milliseconds.
Methods
Called once during the video data loading process. Sets up the audio backend and connects it to the
Player.Starts music playback.
Pauses music playback.
Stops music playback — pauses and seeks back to the beginning.
Seeks to the specified position in milliseconds.
Releases resources held by this
Timer instance.TimerInitOptions
Passed toTimer.initialize when a song is loaded.
The
Player instance that owns this timer.A callback the timer calls periodically to update the player’s media position. The function receives the current position (ms) and returns a
Promise<number> resolving to the accepted position.An event emitter the timer uses to trigger
onTimeUpdate and related player events.PlayerMediaPositionUpdateFunction
Timer implementations to report the current playback position to the Player. The Player may adjust the position and resolves the promise with the accepted value.
BasicTimer
BasicTimer is the built-in Timer implementation included in the SDK. It advances a clock without embedding any audio element, so no sound is played.
BasicTimer is ideal for development and debugging. You can verify that lyrics and animations advance correctly without needing an audio source or network access.Constructor
BasicTimer requires no constructor arguments and implements the full Timer interface.
Usage
SongleTimer
SongleTimer is the full-featured timer implementation that embeds a Songle audio player. It is the default timer used when you do not pass timer in PlayerOptions.
SongleTimer relies on the optional peer dependency songle-api. If not installed, the timer loads it automatically via dynamic import() or <script> tag injection.
Constructor
Properties
Read-only.
true while Songle audio is actively playing.Read-only. Current playback position in milliseconds, calculated in real time.
Get or set the update interval in milliseconds.
Read-only. The underlying Songle Player instance. Accessible after
onTimerReady fires. Use this for Songle-specific APIs.Read-only.
true if Songle Sync is enabled (i.e., accessToken and secretToken were provided in SongleTimerOptions).SongleTimerOptions
Options for instantiating aSongleTimer.
When
true, the timer operates without embedding an audio element — no sound plays. Useful for server-side or test environments.Songle Sync access token. Enables real-time multi-client playback synchronization via Songle Sync.
Songle Sync secret token. Required alongside
accessToken for Songle Sync.A pre-initialized Songle API instance (the object returned by
import Songle from "songle-api"). When not provided, the timer initializes Songle automatically.