How do I insert a music that plays automatically in my Web page? Use on any Web page

Source: Internet
Author: User

Website features do not need too much, their own needs of the good, their own blog slowly improve, a function of the increase, are their own needs and practical, they will cherish the hands!

这音乐的功能很简单,一段代码而已:

<audio controls autoplay= "AutoPlay" loop= "loop" >
<source src= "Test.mp3" type= "Audio/mpeg"/>
If it doesn't play, your browser doesn't support it!
</audio>

Plus there's going to be a player that shows

Image.png

相信谁都能理解,但是几点注意,我后面为什么还要多加一个“loop”?这不是和“autoplay”重复了么?是的,重复,但是不矛盾,我自己的网站如果不加“loop”,是不会自动播放的。为了美观我还会加上hidden,隐藏播放器,达到点进去网页就播放只有很少数而特殊的网页我才会用上音乐!接下来就把代码写到模板页面,然后后台编辑文章页面添加一个文本框,进行方便输入音乐地址。

这样就很方便的在添加文章的时候随意了,当然要在特殊的模板中,不然的话,每一个页面都要加载一个播放器,不是让网站变的很臃肿么?所以复制新建一个模板页面,在需要添加音乐的时候就选择那个模板页面就好了!改版完成,我只在“生活日记”栏目添加了音乐功能,模版的代码改成:

<audio controls autoplay= "AutoPlay" loop= "loop" style= "Display:none;" >
<source src= "{dede:field.shorttitle/}" type= "Audio/mpeg"/>
If it doesn't play, your browser doesn't support it!
</audio>

Need to note is in the column where to modify the article content template!

How do I insert a music that plays automatically in my Web page? Use on any Web page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.