diff options
author | Chris Xiong <chirs241097@gmail.com> | 2021-12-09 02:47:59 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2021-12-09 02:47:59 +0800 |
commit | f03d4118421daa4ca5c711dfbbbbbf2cd282e73d (patch) | |
tree | 8d8290292a0400469374273ba979a4c5bb7bdc0d /libs | |
parent | 39df195220a8c16d610f32ecdc38059fc067e890 (diff) | |
download | web-f03d4118421daa4ca5c711dfbbbbbf2cd282e73d.tar.xz |
Let's fix autoplay for real this time, shall we?
Diffstat (limited to 'libs')
-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 |