Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1c83d3c96 | ||
|
|
89992c84c9 | ||
|
|
58a53e324c | ||
|
|
02058ad17f | ||
|
|
d7365d9546 |
@@ -54,7 +54,7 @@ var option = {
|
||||
mutex: true, // Optional, pause other players when this player playing
|
||||
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
|
||||
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'auto'
|
||||
listmaxheight: '513px', // Optional, max height of play list
|
||||
music: { // Required, music info, see: ###With playlist
|
||||
title: 'Preparation', // Required, music title
|
||||
@@ -74,6 +74,12 @@ var option = {
|
||||
+ `ap.toggle()` // Toggle between play and pause
|
||||
+ `ap.volume(percentage)` // Set volume
|
||||
+ `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
|
||||
|
||||
|
||||
Vendored
+1
-1
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",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"description": "Wow, such a beautiful html5 music player",
|
||||
"main": "dist/APlayer.min.js",
|
||||
"scripts": {
|
||||
"test": "webpack",
|
||||
"start": "webpack-dev-server --hot --progress --inline"
|
||||
"start": "webpack-dev-server --hot --progress --inline --host 0.0.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
+14
-20
@@ -1,4 +1,4 @@
|
||||
console.log("\n %c APlayer 1.5.3 %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');
|
||||
|
||||
@@ -63,10 +63,10 @@ class APlayer {
|
||||
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
|
||||
* @return {String} 00:00 format
|
||||
* @return {String} 00:00 format. 00:00:00 if over an hour long.
|
||||
*/
|
||||
this.secondToTime = (second) => {
|
||||
const add0 = (num) => {
|
||||
@@ -74,7 +74,9 @@ class APlayer {
|
||||
};
|
||||
const min = parseInt(second / 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
|
||||
@@ -110,8 +112,8 @@ class APlayer {
|
||||
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])) {
|
||||
this.lrcIndex = i;
|
||||
this.lrcContents.style.transform = `translateY(${-this.lrcIndex * 20}px)`;
|
||||
this.lrcContents.style.webkitTransform = `translateY(${-this.lrcIndex * 20}px)`;
|
||||
this.lrcContents.style.transform = `translateY(${-this.lrcIndex * 16}px)`;
|
||||
this.lrcContents.style.webkitTransform = `translateY(${-this.lrcIndex * 16}px)`;
|
||||
this.lrcContents.getElementsByClassName('aplayer-lrc-current')[0].classList.remove('aplayer-lrc-current');
|
||||
this.lrcContents.getElementsByTagName('p')[i].classList.add('aplayer-lrc-current');
|
||||
}
|
||||
@@ -138,6 +140,9 @@ class APlayer {
|
||||
if (this.option.showlrc) {
|
||||
this.element.classList.add('aplayer-withlrc');
|
||||
}
|
||||
if (this.option.music.length > 1) {
|
||||
this.element.classList.add('aplayer-list');
|
||||
}
|
||||
|
||||
// fill in HTML
|
||||
let eleHTML = `
|
||||
@@ -170,7 +175,7 @@ class APlayer {
|
||||
- <span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
||||
</span>
|
||||
<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')
|
||||
+ ` </button>
|
||||
<div class="aplayer-volume-bar-wrap">
|
||||
@@ -220,7 +225,6 @@ class APlayer {
|
||||
// fix the width of aplayer bar
|
||||
let bar = {};
|
||||
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
|
||||
if (this.option.narrow) {
|
||||
@@ -246,12 +250,7 @@ class APlayer {
|
||||
const musicIndex = parseInt(listItem[i].getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
||||
if (musicIndex !== this.playIndex) {
|
||||
this.setMusic(musicIndex);
|
||||
if (this.isMobile) {
|
||||
this.pause();
|
||||
}
|
||||
else {
|
||||
this.play();
|
||||
}
|
||||
this.play();
|
||||
}
|
||||
else {
|
||||
this.toggle();
|
||||
@@ -455,12 +454,7 @@ class APlayer {
|
||||
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
||||
this.audio = document.createElement("audio");
|
||||
this.audio.src = this.music.url;
|
||||
if (this.option.preload) {
|
||||
this.audio.preload = this.option.preload;
|
||||
}
|
||||
else {
|
||||
this.audio.preload = this.isMobile ? 'none' : 'metadata';
|
||||
}
|
||||
this.audio.preload = this.option.preload ? this.option.preload : 'auto';
|
||||
|
||||
// show audio time: the metadata has loaded or changed
|
||||
this.audio.addEventListener('durationchange', () => {
|
||||
|
||||
+49
-21
@@ -1,6 +1,6 @@
|
||||
$aplayer-height: 66px;
|
||||
$lrc-height: 40px;
|
||||
$aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
$lrc-height: 30px;
|
||||
$aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
|
||||
.aplayer-narrow {
|
||||
width: $aplayer-height;
|
||||
@@ -13,16 +13,32 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
&.aplayer-narrow {
|
||||
width: $aplayer-height-lrc;
|
||||
}
|
||||
&.aplayer .aplayer-pic {
|
||||
height: $aplayer-height-lrc;
|
||||
width: $aplayer-height-lrc;
|
||||
&.aplayer {
|
||||
.aplayer-pic {
|
||||
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 .aplayer-lrc {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.aplayer-list {
|
||||
&.aplayer {
|
||||
.aplayer-info {
|
||||
border-bottom: 1px solid #e9e9e9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +149,9 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 13px;
|
||||
user-select: text;
|
||||
cursor: default;
|
||||
padding-bottom: 2px;
|
||||
|
||||
.aplayer-title {
|
||||
font-size: 14px;
|
||||
@@ -146,11 +165,13 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
|
||||
.aplayer-controller {
|
||||
position: relative;
|
||||
display: flex;
|
||||
|
||||
.aplayer-bar-wrap {
|
||||
margin: 0 140px 0 5px;
|
||||
margin: 0 0 0 5px;
|
||||
padding: 4px 0;
|
||||
cursor: pointer !important;
|
||||
flex: 1;
|
||||
|
||||
.aplayer-bar {
|
||||
position: relative;
|
||||
@@ -192,12 +213,13 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
}
|
||||
|
||||
.aplayer-time {
|
||||
position: absolute;
|
||||
position: relative;
|
||||
right: 0;
|
||||
bottom: -3px;
|
||||
bottom: 3px;
|
||||
height: 17px;
|
||||
color: #999;
|
||||
font-size: 11px;
|
||||
padding-left: 7px;
|
||||
|
||||
.aplayer-time-inner {
|
||||
vertical-align: middle;
|
||||
@@ -280,7 +302,7 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
margin: -10px 0 10px;
|
||||
margin: -10px 0 7px;
|
||||
|
||||
&:before {
|
||||
position: absolute;
|
||||
@@ -306,17 +328,17 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
width: 100%;
|
||||
height: 33%;
|
||||
content: ' ';
|
||||
background: -moz-linear-gradient(bottom, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
|
||||
background: -webkit-linear-gradient(bottom, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
|
||||
background: linear-gradient(to top, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=0 );
|
||||
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 100%);
|
||||
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,0.8) 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='#ccffffff',GradientType=0 );
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
line-height: 20px !important;
|
||||
height: 20px !important;
|
||||
line-height: 16px !important;
|
||||
height: 16px !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
transition: all 0.5s ease-out;
|
||||
@@ -331,6 +353,8 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
.aplayer-lrc-contents {
|
||||
width: 100%;
|
||||
transition: all 0.5s ease-out;
|
||||
user-select: text;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +397,10 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
|
||||
transition: all 0.2s ease;
|
||||
overflow: hidden;
|
||||
|
||||
&:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user