原文連接: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: