Boolean indicating whether monitoring was successfully stopped
// Stop monitoring during application shutdown
app.on('before-quit', () => {
stopPlaybackMonitoring();
});
// Stop, reconfigure, and restart monitoring
stopPlaybackMonitoring();
setMonitoringConfig({ pollingInterval: 5000 });
startPlaybackMonitoring(mainWindow, clientId, clientSecret);
export function stopPlaybackMonitoring(): boolean {
try {
if (monitoringInterval) {
clearTimeout(monitoringInterval);
monitoringInterval = null;
store.saveLog("Stopped Spotify playback monitoring", "INFO");
} else {
store.saveLog("No active monitoring session to stop", "DEBUG");
}
// Clear the progress update interval when stopping monitoring
if (progressUpdateInterval) {
clearInterval(progressUpdateInterval);
progressUpdateInterval = null;
}
// Reset backoff strategy when stopping
resetBackoff();
return true;
} catch (error) {
store.saveLog(`Failed to stop playback monitoring: ${error}`, "ERROR");
return false;
}
}
Stops the playback monitoring process
Terminates all active monitoring activities including API polling, progress interpolation, and event handling. This function performs a complete and clean shutdown of the monitoring service.
The function handles several important cleanup tasks:
Typical usage scenarios include: