Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在html5中播放广播源_Javascript_Html - Fatal编程技术网

Javascript 无法在html5中播放广播源

Javascript 无法在html5中播放广播源,javascript,html,Javascript,Html,我有以下两个无线电信号源: 无线电1- 第二台- 它们最初都工作正常,但当我将这些源代码放在src前面的HTML中时,它们停止工作,无法播放音频 这是我的密码: const audioButtons=document.querySelectorAll(“.trigger audio”) const buttontopTopAllaudios=document.querySelector(“.fa stop”) 常量getAudioElementFromButton=按钮元素=> But

我有以下两个无线电信号源:

无线电1-

第二台-

它们最初都工作正常,但当我将这些源代码放在
src
前面的HTML中时,它们停止工作,无法播放音频

这是我的密码:





const audioButtons=document.querySelectorAll(“.trigger audio”) const buttontopTopAllaudios=document.querySelector(“.fa stop”) 常量getAudioElementFromButton=按钮元素=> ButtonneElement.querySelector('audio') const stopAudioFromButton=按钮元素=>{ //暂停音频 getAudioElementFromButton(buttonElement).pause() //更新元素类 ButtoneElement.classList.add('fa-play')) ButtonneElement.classList.remove('fa-pause') } const playAudioFromButton=按钮元素=>{ //暂停音频 getAudioElementFromButton(buttonElement.play()) //更新元素类 ButtoneElement.classList.remove('fa-play') ButtoneElement.classList.add('fa-pause') } audioButtons.forEach(audioButton=>{ audioButton.addEventListener('单击',()=>{ //我首先得到这个,因为我必须在做任何事情之前暂停所有音频,所以我必须知道这个音频是否已暂停 const audioElement=getAudioElementFromButton(audioButton) const audioIsPaused=audioElement.paused //启动此音频之前,请停止所有音频 音频按钮。forEach(stopAudioFromButton) 音频广播 ?playAudioFromButton(audioButton)//暂停时播放 :stopAudioFromButton(audioButton)//播放时暂停 }) }) 按钮停止Allaudios.addEventListener('单击',()=>{ 音频按钮。forEach(stopAudioFromButton) })
我将您的代码复制并粘贴到一个HTML文件中,对我来说效果很好。你能分享一些关于你正在测试的浏览器的详细信息吗?@KeeganTeetaert我正在使用最新版本的chrome。你是对的!我刚刚在firefox上测试了它,它工作得非常好。但现在我无法理解这一点。我有一些其他的URL,在chrome上使用相同的代码也能正常工作。这是否会使chrome成为一个糟糕的浏览器,或者应该在我的代码中更改某些内容?@KeeganTeetaert以下是有效的URL:1)2)