Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1c83d3c96 | ||
|
|
89992c84c9 | ||
|
|
58a53e324c | ||
|
|
02058ad17f | ||
|
|
d7365d9546 | ||
|
|
1386beaa27 | ||
|
|
62d146a9dc |
@@ -54,7 +54,7 @@ var option = {
|
|||||||
mutex: true, // Optional, pause other players when this player playing
|
mutex: true, // Optional, pause other players when this player playing
|
||||||
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
|
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
|
||||||
mode: 'random', // Optional, play mode, can be `random` `single` `circulation`(loop) `order`(no loop), default: `circulation`
|
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
|
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'auto'
|
||||||
listmaxheight: '513px', // Optional, max height of play list
|
listmaxheight: '513px', // Optional, max height of play list
|
||||||
music: { // Required, music info, see: ###With playlist
|
music: { // Required, music info, see: ###With playlist
|
||||||
title: 'Preparation', // Required, music title
|
title: 'Preparation', // Required, music title
|
||||||
@@ -74,6 +74,12 @@ var option = {
|
|||||||
+ `ap.toggle()` // Toggle between play and pause
|
+ `ap.toggle()` // Toggle between play and pause
|
||||||
+ `ap.volume(percentage)` // Set volume
|
+ `ap.volume(percentage)` // Set volume
|
||||||
+ `ap.on(event, handler)` // Event binding
|
+ `ap.on(event, handler)` // Event binding
|
||||||
|
+ `ap.setMusic(index)` // Switch music
|
||||||
|
+ `ap.lrc` // Lrc time and text
|
||||||
|
+ `ap.playIndex` // Current playing index
|
||||||
|
+ `ap.audio` // Return native video, most [native api](http://www.w3schools.com/tags/ref_av_dom.asp) are supported
|
||||||
|
+ `dp.audio.currentTime` // Returns the current playback position
|
||||||
|
+ Most [native api](http://www.w3schools.com/tags/ref_av_dom.asp)
|
||||||
|
|
||||||
#### Event binding
|
#### Event binding
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ var ap5 = new APlayer({
|
|||||||
mutex: true,
|
mutex: true,
|
||||||
theme: '#ad7a86',
|
theme: '#ad7a86',
|
||||||
mode: 'random',
|
mode: 'random',
|
||||||
listmaxheight: '60px',
|
listmaxheight: '80px',
|
||||||
music: [
|
music: [
|
||||||
{
|
{
|
||||||
title: 'あっちゅ~ま青春!',
|
title: 'あっちゅ~ま青春!',
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "aplayer",
|
"name": "aplayer",
|
||||||
"version": "1.5.2",
|
"version": "1.5.4",
|
||||||
"description": "Wow, such a beautiful html5 music player",
|
"description": "Wow, such a beautiful html5 music player",
|
||||||
"main": "dist/APlayer.min.js",
|
"main": "dist/APlayer.min.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "webpack",
|
"test": "webpack",
|
||||||
"start": "webpack-dev-server --hot --progress --inline"
|
"start": "webpack-dev-server --hot --progress --inline --host 0.0.0.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
+15
-21
@@ -1,4 +1,4 @@
|
|||||||
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;");
|
console.log("\n %c APlayer 1.5.4 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
|
||||||
|
|
||||||
require('./APlayer.scss');
|
require('./APlayer.scss');
|
||||||
|
|
||||||
@@ -63,10 +63,10 @@ class APlayer {
|
|||||||
this.mode = option.mode;
|
this.mode = option.mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse second to 00:00 format
|
* Parse second to 00:00 format. 00:00:00 if audio is over an hour long.
|
||||||
*
|
*
|
||||||
* @param {Number} second
|
* @param {Number} second
|
||||||
* @return {String} 00:00 format
|
* @return {String} 00:00 format. 00:00:00 if over an hour long.
|
||||||
*/
|
*/
|
||||||
this.secondToTime = (second) => {
|
this.secondToTime = (second) => {
|
||||||
const add0 = (num) => {
|
const add0 = (num) => {
|
||||||
@@ -74,7 +74,9 @@ class APlayer {
|
|||||||
};
|
};
|
||||||
const min = parseInt(second / 60);
|
const min = parseInt(second / 60);
|
||||||
const sec = parseInt(second - min * 60);
|
const sec = parseInt(second - min * 60);
|
||||||
return add0(min) + ':' + add0(sec);
|
const hours = parseInt(min / 60);
|
||||||
|
const minAdjust = parseInt((second / 60) - (60 * parseInt((second / 60) / 60)));
|
||||||
|
return second >= 3600 ? add0(hours) + ':' + add0(minAdjust) + ':' + add0(sec) : add0(min) + ':' + add0(sec);
|
||||||
};
|
};
|
||||||
|
|
||||||
// save lrc
|
// save lrc
|
||||||
@@ -110,8 +112,8 @@ class APlayer {
|
|||||||
for (let i = 0; i < this.lrc.length; i++) {
|
for (let i = 0; i < this.lrc.length; i++) {
|
||||||
if (currentTime >= this.lrc[i][0] && (!this.lrc[i + 1] || currentTime < this.lrc[i + 1][0])) {
|
if (currentTime >= this.lrc[i][0] && (!this.lrc[i + 1] || currentTime < this.lrc[i + 1][0])) {
|
||||||
this.lrcIndex = i;
|
this.lrcIndex = i;
|
||||||
this.lrcContents.style.transform = `translateY(${-this.lrcIndex * 20}px)`;
|
this.lrcContents.style.transform = `translateY(${-this.lrcIndex * 16}px)`;
|
||||||
this.lrcContents.style.webkitTransform = `translateY(${-this.lrcIndex * 20}px)`;
|
this.lrcContents.style.webkitTransform = `translateY(${-this.lrcIndex * 16}px)`;
|
||||||
this.lrcContents.getElementsByClassName('aplayer-lrc-current')[0].classList.remove('aplayer-lrc-current');
|
this.lrcContents.getElementsByClassName('aplayer-lrc-current')[0].classList.remove('aplayer-lrc-current');
|
||||||
this.lrcContents.getElementsByTagName('p')[i].classList.add('aplayer-lrc-current');
|
this.lrcContents.getElementsByTagName('p')[i].classList.add('aplayer-lrc-current');
|
||||||
}
|
}
|
||||||
@@ -138,6 +140,9 @@ class APlayer {
|
|||||||
if (this.option.showlrc) {
|
if (this.option.showlrc) {
|
||||||
this.element.classList.add('aplayer-withlrc');
|
this.element.classList.add('aplayer-withlrc');
|
||||||
}
|
}
|
||||||
|
if (this.option.music.length > 1) {
|
||||||
|
this.element.classList.add('aplayer-list');
|
||||||
|
}
|
||||||
|
|
||||||
// fill in HTML
|
// fill in HTML
|
||||||
let eleHTML = `
|
let eleHTML = `
|
||||||
@@ -170,7 +175,7 @@ class APlayer {
|
|||||||
- <span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
- <span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="aplayer-volume-wrap">
|
<div class="aplayer-volume-wrap">
|
||||||
<button class="aplayer-icon aplayer-icon-volume-down">`
|
<button class="aplayer-icon aplayer-icon-volume-down" ${this.isMobile ? 'style="display: none;"' : ''}>`
|
||||||
+ this.getSVG('volume-down')
|
+ this.getSVG('volume-down')
|
||||||
+ ` </button>
|
+ ` </button>
|
||||||
<div class="aplayer-volume-bar-wrap">
|
<div class="aplayer-volume-bar-wrap">
|
||||||
@@ -220,7 +225,6 @@ class APlayer {
|
|||||||
// fix the width of aplayer bar
|
// fix the width of aplayer bar
|
||||||
let bar = {};
|
let bar = {};
|
||||||
bar.barWrap = this.element.getElementsByClassName('aplayer-bar-wrap')[0];
|
bar.barWrap = this.element.getElementsByClassName('aplayer-bar-wrap')[0];
|
||||||
bar.barWrap.style.marginRight = this.element.getElementsByClassName('aplayer-time')[0].offsetWidth + 5 + 'px';
|
|
||||||
|
|
||||||
// switch to narrow style
|
// switch to narrow style
|
||||||
if (this.option.narrow) {
|
if (this.option.narrow) {
|
||||||
@@ -246,12 +250,7 @@ class APlayer {
|
|||||||
const musicIndex = parseInt(listItem[i].getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
const musicIndex = parseInt(listItem[i].getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
||||||
if (musicIndex !== this.playIndex) {
|
if (musicIndex !== this.playIndex) {
|
||||||
this.setMusic(musicIndex);
|
this.setMusic(musicIndex);
|
||||||
if (this.isMobile) {
|
this.play();
|
||||||
this.pause();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.toggle();
|
this.toggle();
|
||||||
@@ -455,12 +454,7 @@ class APlayer {
|
|||||||
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
||||||
this.audio = document.createElement("audio");
|
this.audio = document.createElement("audio");
|
||||||
this.audio.src = this.music.url;
|
this.audio.src = this.music.url;
|
||||||
if (this.option.preload) {
|
this.audio.preload = this.option.preload ? this.option.preload : 'auto';
|
||||||
this.audio.preload = this.option.preload;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.audio.preload = this.isMobile ? 'none' : 'metadata';
|
|
||||||
}
|
|
||||||
|
|
||||||
// show audio time: the metadata has loaded or changed
|
// show audio time: the metadata has loaded or changed
|
||||||
this.audio.addEventListener('durationchange', () => {
|
this.audio.addEventListener('durationchange', () => {
|
||||||
@@ -785,4 +779,4 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {APlayer};
|
module.exports = APlayer;
|
||||||
+63
-21
@@ -1,6 +1,6 @@
|
|||||||
$aplayer-height: 66px;
|
$aplayer-height: 66px;
|
||||||
$lrc-height: 40px;
|
$lrc-height: 30px;
|
||||||
$aplayer-height-lrc: $aplayer-height + $lrc-height;
|
$aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||||
|
|
||||||
.aplayer-narrow {
|
.aplayer-narrow {
|
||||||
width: $aplayer-height;
|
width: $aplayer-height;
|
||||||
@@ -13,16 +13,32 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
&.aplayer-narrow {
|
&.aplayer-narrow {
|
||||||
width: $aplayer-height-lrc;
|
width: $aplayer-height-lrc;
|
||||||
}
|
}
|
||||||
&.aplayer .aplayer-pic {
|
&.aplayer {
|
||||||
height: $aplayer-height-lrc;
|
.aplayer-pic {
|
||||||
width: $aplayer-height-lrc;
|
height: $aplayer-height-lrc;
|
||||||
|
width: $aplayer-height-lrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-info {
|
||||||
|
margin-left: $aplayer-height-lrc;
|
||||||
|
height: $aplayer-height-lrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-lrc {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-info {
|
||||||
|
padding: 10px 7px 0 7px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&.aplayer .aplayer-info {
|
}
|
||||||
margin-left: $aplayer-height-lrc;
|
|
||||||
height: $aplayer-height-lrc;
|
.aplayer-list {
|
||||||
}
|
&.aplayer {
|
||||||
&.aplayer .aplayer-lrc {
|
.aplayer-info {
|
||||||
display: block;
|
border-bottom: 1px solid #e9e9e9;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +149,9 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
margin-bottom: 13px;
|
margin-bottom: 13px;
|
||||||
|
user-select: text;
|
||||||
|
cursor: default;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
|
||||||
.aplayer-title {
|
.aplayer-title {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -146,11 +165,13 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
|
|
||||||
.aplayer-controller {
|
.aplayer-controller {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
.aplayer-bar-wrap {
|
.aplayer-bar-wrap {
|
||||||
margin: 0 140px 0 5px;
|
margin: 0 0 0 5px;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
cursor: pointer !important;
|
cursor: pointer !important;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
.aplayer-bar {
|
.aplayer-bar {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -192,12 +213,13 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.aplayer-time {
|
.aplayer-time {
|
||||||
position: absolute;
|
position: relative;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: -3px;
|
bottom: 3px;
|
||||||
height: 17px;
|
height: 17px;
|
||||||
color: #999;
|
color: #999;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
padding-left: 7px;
|
||||||
|
|
||||||
.aplayer-time-inner {
|
.aplayer-time-inner {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@@ -280,7 +302,7 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: -10px 0 10px;
|
margin: -10px 0 7px;
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -306,17 +328,17 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 33%;
|
height: 33%;
|
||||||
content: ' ';
|
content: ' ';
|
||||||
background: -moz-linear-gradient(bottom, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
|
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 100%);
|
||||||
background: -webkit-linear-gradient(bottom, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
|
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,0.8) 100%);
|
||||||
background: linear-gradient(to top, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
|
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,0.8) 100%);
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=0 );
|
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ccffffff',GradientType=0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #666;
|
color: #666;
|
||||||
line-height: 20px !important;
|
line-height: 16px !important;
|
||||||
height: 20px !important;
|
height: 16px !important;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
transition: all 0.5s ease-out;
|
transition: all 0.5s ease-out;
|
||||||
@@ -331,6 +353,8 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
.aplayer-lrc-contents {
|
.aplayer-lrc-contents {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
transition: all 0.5s ease-out;
|
transition: all 0.5s ease-out;
|
||||||
|
user-select: text;
|
||||||
|
cursor: default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +367,20 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
height: 0 !important;
|
height: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar{
|
||||||
|
width: 5px;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar-track{
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar-thumb{
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar-thumb:hover{
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
ol {
|
ol {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -359,6 +397,10 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
|||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #efefef;
|
background: #efefef;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ module.exports = {
|
|||||||
output: {
|
output: {
|
||||||
path: BUILD_PATH,
|
path: BUILD_PATH,
|
||||||
filename: 'APlayer.min.js',
|
filename: 'APlayer.min.js',
|
||||||
|
library: 'APlayer',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
umdNamedDefine: true
|
umdNamedDefine: true
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user