@@ -56,6 +56,7 @@ export interface ICplayerViewOption {
5656 style ?: string ;
5757 dark ?: boolean ;
5858 big ?: boolean ;
59+ shadowDom ?: boolean ;
5960 dropDownMenuMode ?: 'bottom' | 'top' | 'none' | string ;
6061}
6162
@@ -69,7 +70,8 @@ const defaultOption: ICplayerViewOption = {
6970 dropDownMenuMode : 'bottom' ,
7071 width : '' ,
7172 size : '12px' ,
72- style : ''
73+ style : '' ,
74+ shadowDom : true
7375}
7476
7577
@@ -129,13 +131,13 @@ export default class cplayerView extends EventEmitter {
129131 } ;
130132 this . player = player ;
131133 if ( this . options . generateBeforeElement ) {
132- if ( ( this . options . element as any ) . createShadowRoot ) {
134+ if ( ( this . options . element as any ) . createShadowRoot && options . shadowDom !== false ) {
133135 this . rootElement = createBeforeShadowElement ( this . options . element , htmlTemplate , style + this . options . style ) ;
134136 } else {
135137 this . rootElement = createBeforeElement ( this . options . element , htmlTemplate , style + this . options . style ) ;
136138 }
137139 } else {
138- if ( ( this . options . element as any ) . createShadowRoot ) {
140+ if ( ( this . options . element as any ) . createShadowRoot && options . shadowDom !== false ) {
139141 this . rootElement = createShadowElement ( this . options . element , htmlTemplate , style + this . options . style ) ;
140142 } else {
141143 this . rootElement = createElement ( this . options . element , htmlTemplate , style + this . options . style ) ;
@@ -165,12 +167,12 @@ export default class cplayerView extends EventEmitter {
165167 this . big ( ) ;
166168 }
167169
168- this . setPoster ( this . player . nowplay . poster || defaultPoster ) ;
170+ // this.setPoster(this.player.nowplay.poster || defaultPoster);
169171 this . setProgress ( this . player . currentTime / this . player . duration ,
170172 this . player . currentTime ,
171173 this . player . duration ) ;
172- this . elementLinks . title . innerText = this . player . nowplay . name ;
173- this . elementLinks . artist . innerText = this . player . nowplay . artist || '' ;
174+ // this.elementLinks.title.innerText = this.player.nowplay.name;
175+ // this.elementLinks.artist.innerText = this.player.nowplay.artist || '';
174176 this . updateLyric ( ) ;
175177 this . updatePlaylist ( ) ;
176178 }
@@ -381,6 +383,11 @@ export default class cplayerView extends EventEmitter {
381383 }
382384
383385 private updateLyric ( playedTime : number = 0 ) {
386+ if ( ! this . player . nowplay ) {
387+ this . setLyric ( null ) ;
388+ return ;
389+ }
390+
384391 if ( this . player . nowplay . lyric && typeof this . player . nowplay . lyric !== 'string' && this . player . played ) {
385392 let lyric = this . player . nowplay . lyric . getLyric ( playedTime * 1000 ) ;
386393 let nextLyric = this . player . nowplay . lyric . getNextLyric ( playedTime * 1000 ) ;
0 commit comments