Playback State Management Module

Provides centralized state management for the playback monitoring system, maintaining a consistent, reliable source of truth for all playback-related data.

Features:

  • Comprehensive playback state object with extensive metadata
  • In-memory state management with controlled access patterns
  • Track history tracking for advanced playback analysis
  • Clean state initialization and reset capabilities
  • Credential management for Spotify API authentication
  • Recent track access prevention mechanisms
  • Playback timing and progress tracking
  • Pause duration monitoring for accurate listening metrics

This module acts as the central data store for the playback monitoring system, maintaining the current playback state and providing controlled access through a set of specialized getter and setter functions. It ensures consistent, predictable state transitions and prevents direct mutation of internal state data.

The state includes both user-facing playback information (track details, artist information, etc.) and internal tracking data (timestamps, history, etc.) necessary for accurate skip detection and listening analytics.

Functions

resetPlaybackState
getPlaybackState
updatePlaybackState
setCredentials
getCredentials
setTrackLastLogged
getTrackLastLogged
setRecentTracks