From 7fb9b6d30ca00876cd7dd3af7741e40d7a1b640a Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 21 Dec 2024 21:34:45 -0500 Subject: Fix multitrack playback for ... god knows what browser. --- libs/music/player.d/main_static.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'libs/music/player.d/main_static.js') diff --git a/libs/music/player.d/main_static.js b/libs/music/player.d/main_static.js index cf2e610..94658fc 100644 --- a/libs/music/player.d/main_static.js +++ b/libs/music/player.d/main_static.js @@ -216,7 +216,6 @@ NSUI={ if(NSUI.selectedplist) NSUI.switch_playlist(NSUI.selectedplist); }; - sh.elem('plistsw').onclick=NSUI.togglePlist; sh.elem('tsliderbase').onclick= sh.elem('tsliderbase').onmousemove=function(e) { @@ -269,13 +268,7 @@ NSUI={ return false; } if(e.key=='c') - if(NSUI.audio.audioTracks.length==2) - { - const t=NSUI.audio.currentTime; - NSUI.audio.audioTracks[0].enabled^=1; - NSUI.audio.audioTracks[1].enabled^=1; - NSUI.audio.currentTime=t; - } + return NSAudio.switchAudioTrack(); return true; }; }, @@ -481,12 +474,22 @@ NSAudio={ }, connect:function() { - if(this.srcnode===null) + if(this.srcnode===null) this.srcnode=this.audioctx.createMediaElementSource(NSUI.audio); this.srcnode.connect(this.anlznode); this.anlznode.connect(this.audioctx.destination); - if(this.audioctx.state!="running")throw "resume required"; + if(this.audioctx.state!="running")throw "resume required"; }, + switchAudioTrack:function() + { + const a = NSUI.audio; + if (a.audioTracks.length != 2) return false; + const t = a.currentTime; + const e = a.audioTracks[0].enabled; + [a.audioTracks[0].enabled, a.audioTracks[1].enabled] = [!e, e]; + a.currentTime = t; + return true; + } }; NSVisualization={ -- cgit v1.2.3