summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2022-03-11 00:50:34 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2022-03-11 00:50:34 +0800
commitcfb2925fb592c117c119edb8cd784b99e2142bc0 (patch)
tree88878a8502c85ed45f3511de72f25f697eba6af8
parent82ff2be462546a4ed59d13d251c1347c8fbd9474 (diff)
downloadweb-cfb2925fb592c117c119edb8cd784b99e2142bc0.tar.xz
still trying to fix autoplay.
-rw-r--r--libs/music/player.d/main_static.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/music/player.d/main_static.js b/libs/music/player.d/main_static.js
index 28ecee5..7070e1d 100644
--- a/libs/music/player.d/main_static.js
+++ b/libs/music/player.d/main_static.js
@@ -472,16 +472,18 @@ NSAudio={
{
window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext;
if(!window.AudioContext)alert('This page requires Web Audio API to work...');
- this.audioctx=new AudioContext;
- this.anlznode=this.audioctx.createAnalyser();
+ if(this.audioctx===null)this.audioctx=new AudioContext;
+ if(this.anlznode===null)this.anlznode=this.audioctx.createAnalyser();
this.anlznode.fftSize=2*NSVisualization.nbins;
NSUI.audio.volume=1;
},
connect:function()
{
+ 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";
},
};
@@ -768,7 +770,7 @@ function init()
let initerr=0;
try{
NSAudio.audioInit();NSAudio.connect();
- }catch(e){initerr=1;}
+ }catch(e){initerr=1;console.log(e);if(NSAudio.audioctx!==null)NSAudio.audioctx.resume();}
if(window.location.hash.length)
{
let p=window.location.hash.substr(1).split('/');