From f03d4118421daa4ca5c711dfbbbbbf2cd282e73d Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Thu, 9 Dec 2021 02:47:59 +0800 Subject: Let's fix autoplay for real this time, shall we? --- libs/music/player.d/main_static.js | 17 +++++++++++++---- 1 file 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{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 -- cgit v1.2.3