Home >Web Front-end >H5 Tutorial >Music player production example (html5)
HTML5+CSS3
(realizing page layout and dynamic effects)
Iconfont
(Use vector icon library to add player related icons)
LESS
(Dynamic CSS writing)
jQuery
(Quickly write js scripts)
gulp+webpack
(Automated build tool to compile and compress LESS, CSS, JS, etc. codes )
Playback pause (click to switch playback status)
Next Song (switch to next song)
Random play (automatically play the next song after the current song is played)
Single loop (click to random The play icon can be switched to a single loop)
Volume adjustment (move the mouse and slide to set the volume)
Song progress bar (can be clicked to switch The progress jumps directly, or you can click the small dot and drag to switch the progress)
Real-time lyrics (click the word to switch the lyrics interface, and automatically scroll the lyrics according to the real-time progress)
Like (click to add an active effect)
Share (can be shared directly to Sina Weibo)
autoplay
Autoplay
loop
Loop play
volume
Volume setting
##currentTime Current playback position
duration Audio length
pause Pause
play Play
ended Returns whether the audio has 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); }
The above is the detailed content of Music player production example (html5). For more information, please follow other related articles on the PHP Chinese website!