原文连接:http://caibaojian.com/html5-audio.htmljavascript
HTML5中的新元素标签css
这些属性和<video>元素标签的属性很相似html
<audio src="song.mp3"></audio>
一样 <audio> 与 </audio> 之间插入的内容是供不支持 audio 元素的浏览器显示的:·html5
//code from http://caibaojian.com/html5-audio.html
<audio src="song.ogg" controls="controls"> Your browser does not support the audio tag. </audio>
经常使用的控制函数:java
只读的媒体属性:css3
可脚本控制的属性值:浏览器
"我"的成长独白 ESTELLE'S AUDIO PLAYER网络
首先,先介绍一下"我"本身,和你同样,我也是有生命的个体,但 (ke) 是 (xi) ,我比你更有灵性 [ 傲娇 ]ide
<body> <audio id='audio'>你的浏览器不支持喔!</audio> <div class='MusicPanel'> <div class='PanelLeft'><div class='circle'><span class='icon glyphicon-heart'></span></div></div> <!-- Like Button --> <div class='PanelRight'> <div class='Prev'><span class='icon glyphicon-step-backward'></span></div> <!-- Prev Song Button --> <div id='Play' class='Play'><span class='icon glyphicon-play'></span></div> <!-- Play & Pause Button --> <div class='Next'><span class='icon glyphicon-step-forward'></span></div> <!-- Next Song Button --> <div class="Song"><span class='SongAuthor'>Greyson Chance</span></br><span class='SongName'>Summertrain</span></div> <!-- Song Title --> <div class="Process"> <!-- Process --> <div class="ProcessAll" ></div> <!-- ProcessAll --> <div class="ProcessNow"></div> <!-- ProcessNow --> <div class="SongTime">00:00 | 00:00</div> <!-- Time --> </div> <!-- Process End --> </div> <!-- PanelRight End --> </div> <!-- MusicPanel End --> </body>
进度条逻辑函数
绘制两条重叠的进度条,一条指示总进度 ProcessAll,另外一条指示已播放的进度 ProcessNow
根据已播放的时间占总时间比,设置 ProcessNow 下 Width 的值,根据CSS的层叠规范,后写的 ProcessNow 的颜色层在最高层
详见 audio.js 函数 TimeSpan()
其次,我不能不穿衣服呀,我须要一件合适的袈裟,人见人爱,花见花开,车见车那啥儿,嘿嘿
.MusicPanel{ width: 400px; height: 100px; margin: 0 auto; border:1px solid #76dba3; } .MusicPanel .PanelLeft{ width: 100px; height: 100px; display: inline-block; text-align: center; background: #76dba3; } .MusicPanel .PanelRight{ width: 260px; height: 80px; display: inline-block; padding: 10px 20px; position: absolute; background: #fdfef6; } .Prev,.Play,.Next{ display: inline-block; margin-right: 5px; } .Prev,.Next{ filter:alpha(opacity=30); -moz-opacity:0.3; opacity:0.3; cursor: not-allowed; } .Prev:hover,.Next:hover{ filter:alpha(opacity=30); -moz-opacity:0.3; opacity:0.3; cursor: not-allowed; } .Song{ display: inline-block; padding-left: 15px; } .SongTime{ float: right; font-family: cursive,microsoft Yahei; font-size: 14px; color:#ee8a87; } .Song:hover{ cursor: default; } .SongAuthor{ font-family: cursive,microsoft Yahei; color:#ee8a87; font-size: 18px; } .SongName{ font-family: cursive,microsoft Yahei; color:#ee8a87; font-size: 13px; } .PanelRight .icon{ display: inline-block; color:#f06d6a; font-size:22px; transition:0.3s; } .PanelRight .Play .icon:hover { cursor: pointer; color: #dd2924; } .PanelLeft .circle{ width: 40px; height: 40px; display: inline-block; margin-top: 30%; line-height: 40px; border-radius: 50%; border:1px solid white; transition: