I have a local radio (Liquidsoap 2.1.4 + Icecast 2.4.4, both in docker), that broadcasts in mp3 format. My local site has a list of stations; if i click on it, a new stream will play. But at the beginning of playback, a short crackle sound is heard.
I tried already animate volume like this:
$(MUSIC).animate({volume: 1}, 500)
...
$(MUSIC).animate({volume: 0}, 500)
but it did not help. I also tried to find other ways, but they were all about playing files, not streaming, and did not help me.
Here is a short version of my code without fade in/fade out (jquery):
window.onload = function(){
const MUSIC = new Audio()
MUSIC.type = "audio/mpeg; codecs='mp3'"
MUSIC.muted = false
function clickPlay(){ // click on the station
MUSIC.volume = volumeLevel // 100% or lower
MUSIC.src = 'http://ip:port/' + id + '.mp3' // e.g., ip:port/trance.mp3
play()
}
//---
function play(){
var playPromise = MUSIC.play()
if (playPromise !== undefined) {
playPromise.then(function() {
//
}).catch(function(error) {
MUSIC.play()
});
}
}
//---
function pause(){
if (MUSIC != undefined) {
MUSIC.pause()
}
}
//---
}
Browser: brave 1.51.118
So, how can i get rid of this crackle sound at the start of playback of the stream?