Javascript 如何检查音频是否为空?
有没有办法知道Javascript 如何检查音频是否为空?,javascript,http,httpresponse,html5-audio,audio-streaming,Javascript,Http,Httpresponse,Html5 Audio,Audio Streaming,有没有办法知道收音机是否为空(没有声音/音频) 有时广播主机忘记打开流,我想在出现这种情况时给最终用户一些反馈。类似于警报的东西,上面写着“电台主持人忘了打开流!!!” 我想要实现的是这样的目标: const radio = new Audio('http://myradiostation.com/stream'); 提前感谢。以下是成功的秘诀: if(radio.isEmpty){ alert('The radio host forgot to turn on the stream!
收音机是否为空(没有声音/音频)
有时广播主机忘记打开流,我想在出现这种情况时给最终用户一些反馈。类似于警报的东西,上面写着“电台主持人忘了打开流!!!”
我想要实现的是这样的目标:
const radio = new Audio('http://myradiostation.com/stream');
提前感谢。以下是成功的秘诀:
if(radio.isEmpty){
alert('The radio host forgot to turn on the stream!!!')
}else{
radio.play()
}
const radio = new Audio('http://myradiostation.com/stream');
radio
.play()
.then(() => {
console.log('success');
})
.catch((error) => {
console.log(error);
alert('The radio host forgot to turn on the stream!!!');
});