55 lines
2.2 KiB
JavaScript
55 lines
2.2 KiB
JavaScript
// Audio Debug Script - Clear corrupted audio data and trigger fresh scan
|
|
|
|
console.log('🧹 Starting comprehensive audio cleanup...');
|
|
|
|
// Clear existing customAudio data completely and restart fresh
|
|
if (window.game && window.game.dataManager) {
|
|
console.log('🗑️ Clearing all existing audio data to start fresh...');
|
|
|
|
// Completely reset audio storage
|
|
window.game.dataManager.set('customAudio', { background: [], ambient: [] });
|
|
console.log('✅ Cleared all customAudio storage');
|
|
|
|
// Clear any cached audio library
|
|
if (window.game.audioManager) {
|
|
window.game.audioManager.audioLibrary = {
|
|
background: { general: [] }
|
|
};
|
|
console.log('✅ Cleared audio library cache');
|
|
}
|
|
|
|
// Now trigger a fresh directory scan if available
|
|
if (window.game.audioManager && window.game.audioManager.scanAudioDirectories) {
|
|
console.log('🔍 Triggering fresh directory scan...');
|
|
window.game.audioManager.scanAudioDirectories().then((scannedFiles) => {
|
|
console.log(`✅ Fresh scan completed - found ${scannedFiles.length} files`);
|
|
|
|
// Refresh the audio manager
|
|
return window.game.audioManager.refreshAudioLibrary();
|
|
}).then(() => {
|
|
console.log('✅ Audio library refreshed with clean data');
|
|
|
|
// Refresh the audio gallery
|
|
if (window.game.loadAudioGallery) {
|
|
window.game.loadAudioGallery();
|
|
console.log('✅ Audio gallery refreshed');
|
|
}
|
|
}).catch(error => {
|
|
console.error('❌ Error during fresh scan:', error);
|
|
});
|
|
} else {
|
|
console.log('⚠️ Directory scanning not available - try the "Scan Directories" button in Manage Audio');
|
|
|
|
// Just refresh what we have
|
|
if (window.game.audioManager) {
|
|
window.game.audioManager.refreshAudioLibrary().then(() => {
|
|
console.log('✅ Audio library refreshed');
|
|
});
|
|
}
|
|
}
|
|
|
|
} else {
|
|
console.error('❌ Game or dataManager not available');
|
|
}
|
|
|
|
console.log('🎯 Cleanup script completed. Check the console for results and try playing audio.'); |