Module playback/track-change

Track Change Detection and Processing Module

Implements sophisticated track change detection and analysis to accurately identify transitions between tracks, distinguish between skips and completions, and maintain comprehensive listening history data.

Features:

  • Robust track change detection with high accuracy
  • Intelligent skip vs. normal progression discrimination
  • Backward navigation identification (prev button)
  • Local history tracking for accurate navigation detection
  • Spotify API history integration for verification
  • Skip event logging with comprehensive metadata
  • Detailed now-playing status updates
  • Listening context awareness (playlist, album, etc.)
  • Edge case handling for app restarts and network issues

This module serves as the coordination layer between raw playback state changes and higher-level skip analytics. It detects when tracks change, determines the nature of those changes, and records appropriate events and metadata for analytical purposes.

The track change system uses a multi-layered approach:

  1. Local history tracking for immediate context
  2. Spotify API history verification for accuracy
  3. Progress-based skip detection algorithms
  4. Pattern analysis for behavioral insights
  5. Edge case handling for reliability

Functions

addToLocalHistory
isBackwardNavigationInLocalHistory
handleTrackChange
logNowPlaying