const initializeAudio = () => {
if (!audioRef.current) {
audioRef.current = new Audio();
audioRef.current.loop = false;
audioRef.current.volume = volume;
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(`https://st4.mediabay.uz/Poytaxt/PoytaxtUz/index.m3u8`);
hls.attachMedia(audioRef.current);
} else {
audioRef.current.src =
"https://st4.mediabay.uz/Poytaxt/PoytaxtUz/index.m3u8";
}
}
if (!audioContextRef.current) {
audioContextRef.current = new (window.AudioContext ||
(window as unknown as { webkitAudioContext?: typeof AudioContext })
.webkitAudioContext)();
const analyser = audioContextRef.current.createAnalyser();
analyser.fftSize = 256;
analyserRef.current = analyser;
const source = audioContextRef.current.createMediaElementSource(
audioRef.current
);
const gainNode = audioContextRef.current.createGain();
gainNode.gain.value = volume;
gainNodeRef.current = gainNode;
source.connect(gainNode);
gainNode.connect(analyser);
analyser.connect(audioContextRef.current.destination);
}
};
< /code>
- Проверено, что аудиоконтекст и анализернод правильно инициализированы. < /li>
Проверено, если CreateMeedieelmentsource (AudioElement) работает правильно с M3U8. /li>
Убедитесь, что Safari обладает разрешением на автооплату. AnalySernode (например, fftsize, SmoothingTimeConstant).
Подробнее здесь: https://stackoverflow.com/questions/794 ... m3u8-audio
Мобильная версия