Spotify Playback Monitoring Core Service

This module forms the heart of the application's playback tracking system, providing real-time monitoring of Spotify playback state with sophisticated error handling, adaptive polling, and skip detection. It orchestrates the entire playback monitoring pipeline and coordinates the various specialized components.

Features:

  • Real-time playback state monitoring with configurable polling intervals
  • Adaptive polling with intelligent battery optimization
  • Exponential backoff strategy for handling API errors
  • Sophisticated track change detection and skip analysis
  • Smooth progress interpolation between API polls
  • Comprehensive error recovery and resilience
  • User interface synchronization and updates
  • Session management with play/pause tracking
  • Device status monitoring and reporting
  • Library status checking and persistence

The monitoring service implements several advanced features to enhance reliability:

  1. Dynamic Polling: Automatically adjusts polling frequency based on:

    • API health (exponential backoff during outages)
    • Battery status (reduced polling on low battery)
    • User configuration preferences
  2. Progress Interpolation: Provides smooth progress updates by:

    • Estimating track position between API polls
    • Synchronizing with actual API responses when received
    • Accounting for pauses and resumptions
  3. State Management: Maintains comprehensive playback state including:

    • Current track details and metadata
    • Playback status and progress
    • Device information
    • Session metrics for analytics

This module serves as the central coordinator for the playback monitoring system, integrating with track change detection, history tracking, and skip analytics to provide comprehensive playback monitoring capabilities.

Functions

setMonitoringConfig
getMonitoringConfig
startPlaybackMonitoring
stopPlaybackMonitoring
isMonitoringActive

References

startPlaybackMonitoring → startPlaybackMonitoring
isMonitoringActive → isMonitoringActive