我想在后台播放我的网页上的声音文件(不希望出现媒体播放器 UI),我的网站将在 Fire-Fox 上运行,我使用了 Embed 元素并设置了 Hidden 属性确实<embed name="myMusic" src="Masgon.mp3" type="audio/midi"
 autostart="false" Hidden="true" loop="true"></embed>
 ,问题是没有声音播放,除非我在这种情况下删除了隐藏属性,播放声音文件并出现媒体播放器 UI,但我不希望那样。
			
			219723 次
		
7 回答
            36        
        
		
<audio src="/music/good_enough.mp3">
<p>If you are reading this, it is because your browser does not support the audio element.     </p>
</audio>
如果你想要控制
<audio src="/music/good_enough.mp3" controls>
<p>If you are reading this, it is because your browser does not support the audio element.</p>
</audio>
并且还使用嵌入
<embed src="/music/good_enough.mp3" width="180" height="90" loop="false" autostart="false" hidden="true" />
    于 2012-11-15T16:53:55.343   回答
    
    
            11        
        
		
<audio src="/music/good_enough.mp3" autoplay>
<p>If you are reading this, it is because your browser does not support the audio element.     </p>
<embed src="/music/good_enough.mp3" width="180" height="90" hidden="true" />
</audio>
对我有用。
于 2014-05-07T03:15:19.730   回答
    
    
            4        
        
		
尽管评论可能为时已晚,但这是解决诸如您的问题的工作代码。
<div id="player">
    <audio autoplay hidden>
     <source src="link/to/file/file.mp3" type="audio/mpeg">
                If you're reading this, audio isn't supported. 
    </audio>
</div>
    于 2017-03-09T13:56:30.500   回答
    
    
            3        
        
		
<audio controls autoplay loop>
  <source src="path/your_song.mp3" type="audio/ogg">
  <embed src="path/your_song.mp3" autostart="true" loop="true" hidden="true"> 
</audio>
[ps。用文件夹和歌曲名称替换“path/your_song.mp3”,例如。“music/samplemusic.mp3”或“media/bgmusic.mp3”等。
于 2018-05-17T05:54:21.060   回答
    
    
            1        
        
		
对我来说,问题是通过删除type属性解决的:
<embed name="myMusic" loop="true" hidden="true" src="Music.mp3"></embed>
当然不是最干净的方式。
如果您使用的是 HTML5: Firefox 不支持 MP3。Wav 和 Ogg 是。在这里您可以找到有关哪种浏览器支持哪种音频类型的概述:http: //www.w3schools.com/html/html5_audio.asp
于 2012-11-15T16:57:06.287   回答
    
    
            1        
        
		
如果您不想显示控件,请尝试此代码
<audio  autoplay>
 <source src="song.ogg"  type="audio/ogg">
Your browser does not support the audio element.
</audio>
    于 2018-07-20T08:46:47.970   回答
    
    
            0        
        
		
如果你想要它只是正常的:
<audio src="sus.mp3">
    <script>alert("Your browser doesn't support the Audio tag!")</script>
</audio>`
如果您希望它在加载时自动启动:(chrome 不支持)
<audio src="sus.mp3" autostart="true">
    <script>alert("Your browser doesn't support the Audio tag!")</script>
</audio>
如果你想要控制
<audio src="sus.mp3" autostart="true" controls>
    <script>alert("Your browser doesn't support the Audio tag!")</script>
</audio>
    于 2022-02-18T06:37:12.440   回答