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