HTML5+CSS3
(實現頁面佈局和動態效果)Iconfont
(使用矢量圖標庫添加播放器相關圖標)LESS
(動態CSS編寫)jQuery
(快速編寫js腳本)gulp+webpack
(自動化構建工具,實現LESS,CSS,JS等編譯和壓縮代碼)autoplay
自動播放loop
循環播放volume
音量設置currentTime
當前播放位置duration
音頻的長度pause
暫停play
播放ended
返回音頻是否已結束_Music.prototype.playMusic = function(){ var _this = this; this.play.on('click', function(){ if (_this.audio.paused) { _this.audio.play(); $(this).html(''); } else { _this.audio.pause(); $(this).html('') } }); }
_Music.prototype.volumeDrag = function(){ var _this = this; this.btn.on('mousedown', function(){ _this.clicking = true; _this.audio.pause(); }) this.btn.on('mouseup', function(){ _this.clicking = false; _this.audio.play(); }) this.progress.on('mousemove click', function(e){ if(_this.clicking || e.type === 'click'){ var len = $(this).width(), left = e.pageX - $(this).offset().left, volume = left / len; if(volume <= 1 || volume >= 0){ _this.audio.currentTime = volume * _this.audio.duration; _this.progressLine.css('width', volume *100 +'%'); } } }); }
_Music.prototype.readyLyric = function(lyric){ this.lyricBox.empty(); var lyricLength = 0; var html = '<div class="lyric-ani" data-height="20">'; lyric.forEach(function(element,index) { var ele = element[1] === undefined ? '^_^歌詞錯誤^_^' : element[1]; html += '<p class="lyric-line" data-id="'+index+'" data-time="' + element[0] + '"> ' + ele + ' </p>'; lyricLength++; }); html += '</div>'; this.lyricBox.append(html); this.onTimeUpdate(lyricLength); }
代碼還有不少就不一一添加了,以爲還行的話能夠點下喜歡(也能夠在個人GitHub給個Star),你的喜歡和Star是我繼續創做的動力,很是感謝!!!源碼加羣javascript
學習過程當中遇到什麼問題或者想獲取學習資源的話,歡迎加入學習交流羣
343599877,咱們一塊兒學前端!css