new option: preload
This commit is contained in:
parent
c5776b2a78
commit
12fc04957d
|
|
@ -58,6 +58,7 @@ var option = {
|
|||
mutex: true, // Optional, pause other players when this player playing
|
||||
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
|
||||
loop: true, // Optional, loop play music, default: true
|
||||
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'metadata' in Desktop, 'none' in mobile
|
||||
music: { // Required, music info, see: ###With playlist
|
||||
title: 'Preparation', // Required, music title
|
||||
author: 'Hans Zimmer/Richard Harvey', // Required, music author
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ var ap1 = new APlayer({
|
|||
showlrc: false,
|
||||
mutex: true,
|
||||
theme: '#e6d0b2',
|
||||
preload: 'metadata',
|
||||
music: {
|
||||
title: 'Preparation',
|
||||
author: 'Hans Zimmer/Richard Harvey',
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -455,7 +455,12 @@
|
|||
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
||||
this.audio = document.createElement("audio");
|
||||
this.audio.src = this.music.url;
|
||||
this.audio.preload = this.isMobile ? 'none' : 'metadata';
|
||||
if (this.option.preload) {
|
||||
this.audio.preload = this.option.preload;
|
||||
}
|
||||
else {
|
||||
this.audio.preload = this.isMobile ? 'none' : 'metadata';
|
||||
}
|
||||
|
||||
// show audio time: the metadata has loaded or changed
|
||||
this.audio.addEventListener('durationchange', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue