0

I am doing a project for my computer science class in which I am adding audio into my website. I am doing this in cloud 9. And I have a folder of different songs on a different folder. I need to be able to access the song from the higher folder. People have been saying to use this code:

    <source src="../folder/filename.mp3" type=mpeg">

But the code was given to me fro images, I have not been able to do it with a song. When I use this code I get the normal looking play button on my website, but it is grayed out. I have been able to get it to work, but only if I take the song out of the folder and put it at the same level as the file. I have also tested different audio files to see if that is the problem.

4

1 回答 1

2

使用绝对站点 URI 路由,您的声音文件地址以 a 开头,/因此表示从 URL 的根开始的路径。

例如:
您当前的输出文件是,比如说,www.site.com/output/file.html并且您想从中加载声音,www.site.com/sounds/laugh.mp3那么您只需使用/sounds/laugh.mp3地址的一部分作为您的参考。因为它以 a 开头,/这表示它是一个绝对站点 URL,并表示根 HTML 目录,而不是特定于页面的 url。

 <source src="/sounds/filename.mp3" type=mpeg">

如果您使用这样的相对路径,../sounds/filename.mp3如果您在基本文件夹 ( www.site.com/index.html) 或更深的目录树(如www.site.com/sounds/silly/horses.html. 但是绝对路径总是有效的(只要目标文件存在并且可以访问)。


提示:确保您还上传了声音文件!

于 2016-10-15T15:57:03.333 回答