diff options
-rw-r--r-- | libs/music/player.d/main_static.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/music/player.d/main_static.js b/libs/music/player.d/main_static.js index b0f42ae..726b5cf 100644 --- a/libs/music/player.d/main_static.js +++ b/libs/music/player.d/main_static.js @@ -93,7 +93,7 @@ NSPlayer={ const fmt=NSPlayer.get_preferred_or_default_format(); NSUI.audio.src=`//filestorage.chrisoft.org/music/${fmt}/${this.tracks[id].title}.${fmt}`; NSUI.audio.load(); - NSUI.audio.play(); + return NSUI.audio.play(); }, next:function() { @@ -376,7 +376,7 @@ NSUI={ { if(NSPlayer.plistname!=this.selectedplist) this.switch_playlist(this.selectedplist); - NSPlayer.play(id); + return NSPlayer.play(id); }, set_highlighted:function(pl,t) { @@ -774,10 +774,18 @@ function init() NSUI.switch_playlist(p[0],true); let id=0; for(;id<NSPlayer.tracks.length&&NSPlayer.tracks[id].title!=p[1];++id); - if(id<NSPlayer.tracks.length)NSUI.switch_track(id); + if(id<NSPlayer.tracks.length) + { + const p=NSUI.switch_track(id); + if(p!=undefined) + p.then(_=>{sh.elem('overlay').style.display='none';}).catch(e=>{}); + else + //this browser is from an era before this autoplay policy mess, + //assume it succeeded + sh.elem('overlay').style.display='none'; + } } }catch(e){return;} - sh.elem('overlay').style.display='none'; } sh.elem('overlay').onclick(); }, @@ -788,6 +796,7 @@ function init() NSUI.audio.ontimeupdate=NSUI.timeUpdate; NSUI.audio.onended=NSPlayer.next.bind(NSPlayer); NSUI.audio.onplay=NSUI.audio.ondurationchange=function(){ + if(!NSUI.audio.audioTracks)return; if(NSUI.audio.audioTracks.length==2) sh.elem('mt').style.display='inline'; else |