2025-04-02 20:42:47 -03:00
|
|
|
"use client";
|
2025-03-30 16:42:51 -03:00
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
2025-04-26 21:44:35 -03:00
|
|
|
export function SoundInitializer({ children }) {
|
2025-03-30 16:42:51 -03:00
|
|
|
const [isReady, setIsReady] = useState(false);
|
2025-04-26 21:44:35 -03:00
|
|
|
const [error, setError] = useState(null);
|
2025-03-30 16:42:51 -03:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const initializeSounds = async () => {
|
|
|
|
try {
|
2025-04-26 21:44:35 -03:00
|
|
|
// Simulate sound initialization
|
2025-03-30 16:42:51 -03:00
|
|
|
setIsReady(true);
|
|
|
|
} catch (err) {
|
2025-04-26 21:44:35 -03:00
|
|
|
setError(err.message || 'Failed to initialize sounds');
|
2025-03-30 16:42:51 -03:00
|
|
|
}
|
|
|
|
};
|
2025-03-30 19:04:24 -03:00
|
|
|
initializeSounds();
|
2025-03-30 16:42:51 -03:00
|
|
|
}, []);
|
|
|
|
|
2025-03-30 19:04:24 -03:00
|
|
|
if (error) {
|
2025-04-26 21:44:35 -03:00
|
|
|
return <div className="error-container"><p>Error: {error}</p></div>;
|
2025-03-30 16:42:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isReady) {
|
2025-04-26 21:44:35 -03:00
|
|
|
return <div className="loading-container"><p>Loading sounds...</p></div>;
|
2025-03-30 16:42:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
return <>{children}</>;
|
|
|
|
}
|