脚本宝典收集整理的这篇文章主要介绍了音乐播放器的制作实例(html5),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
Iconfont
(使用矢量图标库添加播放器相关图标)
LESS
(动态CSS编写)
jquery
(快速编写js脚本)
gulp+webpack
(自动化构建工具,实现LESS,CSS,JS等编译和压缩代码)
播放暂停(点击切换播放状态)
下一曲(切换下一首)
随机播放(当前歌曲播放完自动播放下一曲)
单曲循环(点击随机播放图标可切换成单曲循环)
实时歌词(点击词,切换歌词界面,根据实时进度自动滚动歌词)
喜欢(点击添加了一个active效果)
分享(可以直接分享到新浪微博)
_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是我继续创作的动力,非常感谢!!!源码加群
以上就是音乐播放器的制作实例(html5)的详细内容,更多请关注脚本宝典其它相关文章!
以上是脚本宝典为你收集整理的音乐播放器的制作实例(html5)全部内容,希望文章能够帮你解决音乐播放器的制作实例(html5)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。