我如何/实际/将mp3链接到html? [英] How do I /actually/ link mp3 into html?

查看:106
本文介绍了我如何/实际/将mp3链接到html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习如何使用它;不确定如何将音频文件链接到脚本中。我试图做的是有一个小型音频播放器。

 < audio controls width =100height = 100\" > 
< source src =somethin.mp3type =audio / mp3>
<! - 旧版浏览器的回退 - >
您的浏览器不支持html5音频
< / audio>


解决方案

这一切都取决于文件位置。对于上面的脚本,你会将你的somethin.mp3放在与你的html文件相同的位置。如果你想把它放在一个子文件夹中(假设你的包含.mp3的文件夹被称为音频文件),它会是< source src =audio / somethin.mp3type =audio / mp3 > 。如果它在第二个子文件夹中(比如说第二个子文件夹被称为html_sound),那么它将是< source src =audio / html_sound / somethin.mp3type =audio / mp3> 。如果你想使用一个字典,你可以使用< source src =../ somethin.mp3type =audio / mp3> 。两个字典向上将是< source src =../../ somethin.mp3type =audio / mp3> 等等。

只需复制字典名称即可进入文件夹,并使用 ../ 来上一个文件夹。



您的代码也不会以< / audio> 标签结尾(它必须),它的 type =audio / mpeg not type =audio / mp3



在Chrome,Edge或Internet Explorer中(如果您有Windows)最好测试脚本也可以,但不要 在Firefox中测试它或歌剧,因为它支持.ogg文件(我知道W3schools说,但它只是一个过时的浏览器,它不会工作)。



你可能想查看一下。



如果您已完成链接或图片,它们完全相同。


I've just started learning how to use this; unsure on how linking audio files into the script works. All I'm trying to do is have a small audio player.

<audio controls width="100" height="100">
  <source src="somethin.mp3" type="audio/mp3">
  <!-- Fallback for older browsers -->
  Your browser doesn't support html5 audio
</audio>

解决方案

It all depends on the file location. For your script above you would put your somethin.mp3 in the same location as you html file. If you want to put it in a sub folder (say your folder containing the .mp3 was called audio) it would be <source src="audio/somethin.mp3" type="audio/mp3">. If it was in a second sub folder (say the second was called html_sound) then it would be <source src="audio/html_sound/somethin.mp3" type="audio/mp3">. If you want to go one dictionary up you would use <source src="../somethin.mp3" type="audio/mp3">. Two dictionaries up would be <source src="../../somethin.mp3" type="audio/mp3"> and so on.

Just copy the dictionary name to go into a folder and use ../ to go up one folder.

also your code does not end with </audio> tag (It MUST) and it's type="audio/mpeg" not type="audio/mp3".

Best test the script in Chrome, Edge or Internet Explorer (if you have Windows) are OK too but do not test it in Firefox or Opera as it supports .ogg files (I know W3schools says it does but all you need is an outdated browser and it will not work).

You might want to check this out.

If you have done links or images they are exactly the same.

这篇关于我如何/实际/将mp3链接到html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆