diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/music/player.d/main_static.js | 8 |
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('/'); |