Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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 如何解决在各种浏览器中HTML中不播放音频的问题_Javascript_Html_Audio_Getelementbyid_Qualtrics - Fatal编程技术网

Javascript 如何解决在各种浏览器中HTML中不播放音频的问题

Javascript 如何解决在各种浏览器中HTML中不播放音频的问题,javascript,html,audio,getelementbyid,qualtrics,Javascript,Html,Audio,Getelementbyid,Qualtrics,我在各种浏览器中播放以下mp3,有时播放,有时不播放。特别是现在,它不再在Chrome中使用,而是在Firefox中使用: http://langcomplab.net/Most_Precious_Possession_Master.mp3 下面是它的代码: The second auditory story is titled, “The Most Precious Possession.” Press the “Play Stor

我在各种浏览器中播放以下mp3,有时播放,有时不播放。特别是现在,它不再在Chrome中使用,而是在Firefox中使用:

http://langcomplab.net/Most_Precious_Possession_Master.mp3
下面是它的代码:

The second auditory story is titled, “The Most Precious Possession.” Press the “Play Story” button to begin listening to the story; after you have finished listening to the story, you will answer a set of questions about the story.
<div>
<audio id="audio3" src="http://langcomplab.net/Most_Precious_Possession_Master.mp3" style="width:50%">Canvas not supported</audio>
</div>

<p>&nbsp;</p>

<div><button name="play" onclick="disabled=true" style="height:25px; width:200px" type="button">Play Story</button></div>
所以我不确定怎么解决。我正在使用Qualtrics创建音频调查

更新: 尽管我将代码更改为以下格式,但并不是说浏览器不支持这种格式。我不确定我错过了什么。以下是一个屏幕截图:

id=“audio3”src=”http://langcomplab.net/Honey_Gatherers_Master.mp3“style=“width:50%”type=“audio/mpeg”您的浏览器不支持此音频格式。

您可以使用以下方法:

<div>
<audio controls>
  <source src="http://langcomplab.net/Most_Precious_Possession_Master.mp3"type="audio/mpeg">
  Your browser does not support this audio format.
</audio>
</div>

您的浏览器不支持此音频格式。
它应该适用于任何现代浏览器(需要HTML5)。希望有帮助

编辑:要使其与按钮一起工作,而不显示HTML5控件,您可以使用:

The second auditory story is titled...
<div>
<audio controls id="reader" style="display:none">
  <source src="http://langcomplab.net/Most_Precious_Possession_Master.mp3"type="audio/mpeg">
  Your browser does not support this audio format.
</audio>
</div>
<input id="Play Story" type="button" value="Play Story" onclick="document.getElementById('reader').play();" />
第二个听觉故事的标题是。。。
您的浏览器不支持此音频格式。

您能看到我问题中的更新吗?谢谢。您是否允许它有时间加载内容?酒吧应该有一条白线,显示youtube上加载的内容。是的。我也不想使用HTML5音频播放设计。我想使用我自己的按钮,如问题所示。如何摆脱显示的默认播放器?我添加了style=“display:none”和一个按钮,根据其id使用javascript播放。如果您有多个音频读取器,您可能需要使用比“reader”更具体的id,但我以它为例。所以现在它有时播放音频,有时不在同一个浏览器中,原因是与音频文件的远程主机有关吗?
<div>
<audio controls>
  <source src="http://langcomplab.net/Most_Precious_Possession_Master.mp3"type="audio/mpeg">
  Your browser does not support this audio format.
</audio>
</div>
The second auditory story is titled...
<div>
<audio controls id="reader" style="display:none">
  <source src="http://langcomplab.net/Most_Precious_Possession_Master.mp3"type="audio/mpeg">
  Your browser does not support this audio format.
</audio>
</div>
<input id="Play Story" type="button" value="Play Story" onclick="document.getElementById('reader').play();" />