File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ const setTheme = (index) => {
144144 }
145145} ;
146146setTheme ( ap5 . list . index ) ;
147- ap5 . on ( 'listswitch' , ( index ) => {
148- setTheme ( index ) ;
147+ ap5 . on ( 'listswitch' , ( data ) => {
148+ setTheme ( data . index ) ;
149149} ) ;
150150
151151const ap6 = new APlayer ( {
@@ -188,18 +188,17 @@ const ap7 = new APlayer({
188188 }
189189} ) ;
190190
191- let ap8 ;
191+ const ap8 = new APlayer ( {
192+ element : document . getElementById ( 'player8' ) ,
193+ mutex : true ,
194+ theme : '#ad7a86' ,
195+ order : 'random' ,
196+ lrcType : 3 ,
197+ fixed : true ,
198+ } ) ;
192199$ . ajax ( {
193200 url : 'https://api.i-meto.com/meting/api?server=netease&type=playlist&id=35798529' ,
194201 success : function ( list ) {
195- ap8 = new APlayer ( {
196- element : document . getElementById ( 'player8' ) ,
197- mutex : true ,
198- theme : '#ad7a86' ,
199- order : 'random' ,
200- lrcType : 3 ,
201- fixed : true ,
202- audio : JSON . parse ( list )
203- } ) ;
202+ ap8 . list . add ( JSON . parse ( list ) ) ;
204203 }
205204} ) ;
Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
8585 box-shadow : none ;
8686
8787 .aplayer-list {
88- margin-bottom : 66px ;
88+ margin-bottom : 65px ;
89+ border : 1px solid #eee ;
90+ border-bottom : none ;
8991 }
9092
9193 .aplayer-body {
Original file line number Diff line number Diff line change @@ -55,6 +55,18 @@ class List {
5555 this . player . events . trigger ( 'listadd' , {
5656 audios : audios ,
5757 } ) ;
58+
59+ if ( Object . prototype . toString . call ( audios ) !== '[object Array]' ) {
60+ audios = [ audios ] ;
61+ }
62+ audios . map ( ( item ) => {
63+ item . name = item . name || item . title || 'Audio name' ;
64+ item . artist = item . artist || item . author || 'Audio artist' ;
65+ item . cover = item . cover || item . pic ;
66+ item . type = item . type || 'normal' ;
67+ return item ;
68+ } ) ;
69+
5870 const wasSingle = ! ( this . audios . length > 1 ) ;
5971 const wasEmpty = this . audios . length === 0 ;
6072
@@ -95,6 +107,7 @@ class List {
95107 list [ index ] . remove ( ) ;
96108
97109 this . audios . splice ( index , 1 ) ;
110+ this . lrc . parsed . splice ( index , 1 ) ;
98111
99112 if ( index === this . index ) {
100113 if ( this . audios [ index ] ) {
@@ -165,6 +178,7 @@ class List {
165178 this . player . container . classList . remove ( 'aplayer-withlist' ) ;
166179 this . player . pause ( ) ;
167180 this . audios = [ ] ;
181+ this . lrc . parsed = [ ] ;
168182 this . player . audio . src = '' ;
169183 this . player . template . listOl . innerHTML = '' ;
170184 this . player . template . pic . style . backgroundImage = '' ;
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ class Lrc {
55 this . container = options . container ;
66 this . async = options . async ;
77 this . player = options . player ;
8- this . content = options . content ;
98 this . parsed = [ ] ;
109 this . index = 0 ;
1110 this . current = [ ] ;
@@ -47,8 +46,8 @@ class Lrc {
4746 switch ( index ) {
4847 if ( ! this . parsed [ index ] ) {
4948 if ( ! this . async ) {
50- if ( this . content [ index ] ) {
51- this . parsed [ index ] = this . parse ( this . content [ index ] ) ;
49+ if ( this . player . list . audios [ index ] . lrc ) {
50+ this . parsed [ index ] = this . parse ( this . player . list . audios [ index ] . lrc ) ;
5251 }
5352 else {
5453 this . parsed [ index ] = [ [ '00:00' , 'Not available' ] ] ;
@@ -73,7 +72,7 @@ class Lrc {
7372 this . current = this . parsed [ index ] ;
7473 }
7574 } ;
76- const apiurl = this . content [ index ] ;
75+ const apiurl = this . player . list . audios [ index ] . lrc ;
7776 xhr . open ( 'get' , apiurl , true ) ;
7877 xhr . send ( null ) ;
7978 }
Original file line number Diff line number Diff line change @@ -79,7 +79,6 @@ class APlayer {
7979 this . lrc = new Lrc ( {
8080 container : this . template . lrc ,
8181 async : this . options . lrcType === 3 ,
82- content : this . options . audio . map ( ( item ) => item . lrc ) ,
8382 player : this ,
8483 } ) ;
8584 }
You can’t perform that action at this time.
0 commit comments