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