# PlaybackSession Source: https://www.nianticspatial.com/docs/api/kotlin/com.nianticspatial.nsdk.playback.PlaybackSession/ PlaybackSession --- ## Declaration class PlaybackSession ## Summary 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). --- ## Properties | Name | Type | Summary | | --- | --- | --- | | dataset | PlaybackDataset | - | --- ## Functions | Name | Type | Summary | | --- | --- | --- | | clearOnFrameListener | void | Clears the frame listener. | | currentFrameIndex | Int | Current frame index (0 until [dataset][PlaybackDataset].frameCount). | | currentPlaybackFrame | PlaybackFrame? | Last frame delivered to the listener; null before any frame or after [pause]. | | dispose | void | 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]) toprevent the listener lambda from retaining a reference to a destroyed component.After dispose, this session should not be reused. | | hasDepth | Boolean | Delegates to [PlaybackDataset.hasDepth]. | | isPlaying | Boolean | True when the session has been started and not yet paused. | | pause | void | Stops the playback loop. Current index is preserved so [play] resumes from the next frame. | | play | void | 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. | | seekToStart | void | Resets playback to the first frame. Call before [play] to begin from the beginning; safe to call while paused. | | setOnFrameListener | void | Sets the callback invoked for each loaded frame. Call before [play]. | ---