audio load

Signed-off-by: ale <ale@manalejandro.com>
This commit is contained in:
ale 2025-05-20 01:45:27 +02:00
parent 5f1a81abb1
commit 685d928215
Signed by: ale
GPG Key ID: 244A9C4DAB1C0C81

View File

@ -1,10 +1,9 @@
import "./App.css";
import { useCallback, useEffect, useRef, useState } from "react";
import { useEffect, useRef, useState } from "react";
import WaveForm from "./WaveForm";
const App = () => {
const [audioUrl, setAudioUrl] = useState(),
[analyzerData, setAnalyzerData] = useState(null),
const [analyzerData, setAnalyzerData] = useState(null),
[bounce, setBounce] = useState(''),
[json, setJson] = useState({}),
[currentVolume, setCurrentVolume] = useState(0.5),
@ -80,14 +79,13 @@ const App = () => {
useEffect(() => {
loadData()
loadListeners()
setAudioUrl('/stream.mp3')
audioAnalyzer()
const inter = setInterval(() => {
loadData()
loadListeners()
}, (Math.floor(Math.random() * 20) + 10) * 1000)
return () => clearInterval(inter)
}, [])
}, [audioElmRef.current])
useEffect(() => {
if (audioElmRef.current && audioElmRef.current.volume !== currentVolume && currentVolume >= 0 && currentVolume <= 1) {
audioElmRef.current.volume = currentVolume
@ -120,7 +118,7 @@ const App = () => {
<button onClick={() => setMuted(true)}>Mute 🔇</button>
}
</div>
<audio src={audioUrl} ref={audioElmRef} volume={currentVolume} preload={"none"} muted={muted} />
<audio src={"/stream.mp3"} ref={audioElmRef} volume={currentVolume} preload={"none"} muted={muted} controls={"none"} />
</>
)
}