random mode: from first music; play list: click to jump

This commit is contained in:
DIYgod 2016-09-19 11:38:24 +08:00
parent 9459d76b4b
commit fa0017c55d
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506
6 changed files with 18 additions and 7 deletions

View File

@ -55,7 +55,7 @@ var option = {
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
mode: 'random', // Optional, play mode, can be `random` `single` `circulation`(loop) `order`(no loop), default: `circulation`
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'metadata' in Desktop, 'none' in mobile
listmaxhight: '513px', // Optional, max height of play list
listmaxheight: '513px', // Optional, max height of play list
music: { // Required, music info, see: ###With playlist
title: 'Preparation', // Required, music title
author: 'Hans Zimmer/Richard Harvey', // Required, music author

View File

@ -107,6 +107,7 @@ var ap5 = new APlayer({
mutex: true,
theme: '#ad7a86',
mode: 'random',
listmaxheight: '60px',
music: [
{
title: 'あっちゅ~ま青春!',

2
dist/APlayer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "aplayer",
"version": "1.5.1",
"version": "1.5.2",
"description": "Wow, such a beautiful html5 music player",
"main": "dist/APlayer.min.js",
"scripts": {

View File

@ -1,4 +1,4 @@
console.log("\n %c APlayer 1.5.1 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
console.log("\n %c APlayer 1.5.2 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
require('./APlayer.scss');
@ -190,7 +190,7 @@ class APlayer {
</div>`;
if (this.multiple) {
eleHTML += `
<div class="aplayer-list" ${this.option.listmaxhight ? `style="max-height: ${this.option.listmaxhight}` : ``}">
<div class="aplayer-list" ${this.option.listmaxheight ? `style="max-height: ${this.option.listmaxheight}` : ``}">
<ol>`;
for (let i = 0; i < this.option.music.length; i++) {
eleHTML += `
@ -406,7 +406,13 @@ class APlayer {
});
}
this.setMusic(0);
if (this.mode === 'random') {
let random = parseInt(Math.random() * this.option.music.length);
this.setMusic(random);
}
else {
this.setMusic(0);
}
instances.push(this);
}
@ -441,6 +447,10 @@ class APlayer {
this.audio.currentTime = 0;
}
if (this.multiple) {
this.element.getElementsByClassName('aplayer-list')[0].scrollTop = indexMusic * 33;
}
// get this audio object
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
this.audio = document.createElement("audio");