Skip to main content
API Reference com.nianticspatial.nsdk.playback

PlaybackSession

Runs a timed loop over a [PlaybackDataset], loading one frame per tick and notifying a listener. Use [play] to begin playback and [pause] to stop; the loop wraps to frame 0 at end. Call [setOnFrameListener] before [play] to receive each [PlaybackFrame]; the listener may be invoked from a background thread (post to main in the sample if needed).

Declaration

class PlaybackSession

Properties

NameTypeSummary
datasetPlaybackDataset
-

Functions

NameTypeSummary
clearOnFrameListenervoid
Clears the frame listener.
currentFrameIndexInt
Current frame index (0 until [dataset][PlaybackDataset].frameCount).
currentPlaybackFramePlaybackFrame?
Last frame delivered to the listener; null before any frame or after [pause].
disposevoid
Stops playback and releases all held references. Call from the owning component's teardown (e.g. [androidx.lifecycle.ViewModel.onCleared] or [android.app.Activity.onDestroy]) to prevent the listener lambda from retaining a reference to a destroyed component. After dispose, this session should not be reused.
hasDepthBoolean
Delegates to [PlaybackDataset.hasDepth].
isPlayingBoolean
True when the session has been started and not yet paused.
pausevoid
Stops the playback loop. Current index is preserved so [play] resumes from the next frame.
playvoid
Starts the playback loop on a background thread. Delivers frames every [PlaybackDataset.frameInterval] seconds; at end of dataset wraps to index 0. No-op if already playing.
seekToStartvoid
Resets playback to the first frame. Call before [play] to begin from the beginning; safe to call while paused.
setOnFrameListenervoid
Sets the callback invoked for each loaded frame. Call before [play].