Skip to content

Commit d7365d9

Browse files
committed
Make music title and lrc selectable; click list to play next song in mobile: close DIYgod#69
1 parent 1386bea commit d7365d9

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var option = {
5454
mutex: true, // Optional, pause other players when this player playing
5555
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
5656
mode: 'random', // Optional, play mode, can be `random` `single` `circulation`(loop) `order`(no loop), default: `circulation`
57-
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'metadata' in Desktop, 'none' in mobile
57+
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'auto'
5858
listmaxheight: '513px', // Optional, max height of play list
5959
music: { // Required, music info, see: ###With playlist
6060
title: 'Preparation', // Required, music title
@@ -74,6 +74,12 @@ var option = {
7474
+ `ap.toggle()` // Toggle between play and pause
7575
+ `ap.volume(percentage)` // Set volume
7676
+ `ap.on(event, handler)` // Event binding
77+
+ `ap.setMusic(index)` // Switch music
78+
+ `ap.lrc` // Lrc time and text
79+
+ `ap.playIndex` // Current playing index
80+
+ `ap.audio` // Return native video, most [native api](http://www.w3schools.com/tags/ref_av_dom.asp) are supported
81+
+ `dp.audio.currentTime` // Returns the current playback position
82+
+ Most [native api](http://www.w3schools.com/tags/ref_av_dom.asp)
7783

7884
#### Event binding
7985

dist/APlayer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/APlayer.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "aplayer",
3-
"version": "1.5.3",
3+
"version": "1.5.4",
44
"description": "Wow, such a beautiful html5 music player",
55
"main": "dist/APlayer.min.js",
66
"scripts": {
77
"test": "webpack",
8-
"start": "webpack-dev-server --hot --progress --inline"
8+
"start": "webpack-dev-server --hot --progress --inline --host 0.0.0.0"
99
},
1010
"repository": {
1111
"type": "git",

src/APlayer.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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;");
1+
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;");
22

33
require('./APlayer.scss');
44

@@ -246,12 +246,7 @@ class APlayer {
246246
const musicIndex = parseInt(listItem[i].getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
247247
if (musicIndex !== this.playIndex) {
248248
this.setMusic(musicIndex);
249-
if (this.isMobile) {
250-
this.pause();
251-
}
252-
else {
253-
this.play();
254-
}
249+
this.play();
255250
}
256251
else {
257252
this.toggle();
@@ -455,12 +450,7 @@ class APlayer {
455450
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
456451
this.audio = document.createElement("audio");
457452
this.audio.src = this.music.url;
458-
if (this.option.preload) {
459-
this.audio.preload = this.option.preload;
460-
}
461-
else {
462-
this.audio.preload = this.isMobile ? 'none' : 'metadata';
463-
}
453+
this.audio.preload = this.option.preload ? this.option.preload : 'auto';
464454

465455
// show audio time: the metadata has loaded or changed
466456
this.audio.addEventListener('durationchange', () => {

src/APlayer.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
133133
white-space: nowrap;
134134
text-overflow: ellipsis;
135135
margin-bottom: 13px;
136+
user-select: text;
137+
cursor: default;
136138

137139
.aplayer-title {
138140
font-size: 14px;
@@ -331,6 +333,8 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height;
331333
.aplayer-lrc-contents {
332334
width: 100%;
333335
transition: all 0.5s ease-out;
336+
user-select: text;
337+
cursor: default;
334338
}
335339
}
336340

0 commit comments

Comments
 (0)