# Problem with HTML5 build on NW.js

**URL:** <https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116>\
**Category:** FMOD Engine\
**Tags:** html5, javascript\
**Created:** [August 10, 2022, 6:54pm UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116 "2022-08-10T18:54:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![creta5164](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creta5164/32/1757_2.png) [@creta5164](https://qa.fmod.com/u/creta5164)\
**Post date:** [August 10, 2022, 6:54pm UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/1 "2022-08-10T18:54:17Z")

</div>

I’m testing the newest version of the FMOD HTML5 build (upstream wasm) in the NW.js environment.

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/ee1a10d86c1a59d3d1316b4ab4fab6cadd378cd8.png)  
It recognizes it as a Node environment, but doesn’t recognize \_\_dirname and \_\_filename because some features work slightly differently between Node and NW.js.

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/7d937eb5da290c0a1431cacab57a04241757cba3.png)  
Even if I hardcoded the directory and filename, it couldn’t find the wasm file.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c0e039687f760c1a68a88ecdf9a2000c1a783864.png)  
So, I modified a part of the code as shown in the picture to force FMOD to recognize it as a web environment.  
(If you can’t see it well, you can see that false is added as the first condition in the ENVIRONMENT\_IS\_NODE=typeof… part.)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/236bda775e187a338f009d953cdff4a48dd9a0c9.png)  
Then, this time, the sound is not played until the user interacts with it, although it may not be the behavior of the FMOD recognized as a web environment.  
There is also a problem because there is also no way to override this and force play.

[![](https://img.youtube.com/vi/YcVaRldGb4c/maxresdefault.jpg "[FMOD\_MV.js] DOWNFALLEN demonstration (SPOILER)") ](https://www.youtube.com/watch?v=YcVaRldGb4c)

Still, in the version 2.01.13, I was initially looking for FMOD to test its workings, ignore it and play was the default, so I used it to solve the problems I was facing at the time.

However, since this will make it impossible to update the version and use the new features, I wonder if we can expect improvements in this area in the future.

---

<div class="post-metadata">

**Author:** ![creta5164](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creta5164/32/1757_2.png) [@creta5164](https://qa.fmod.com/u/creta5164)\
**Post date:** [August 10, 2022, 7:06pm UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/2 "2022-08-10T19:06:13Z")

</div>

+ Does anyone use FMOD in Electron, which is more general than NW.js?  
If you have had such a recent experience, please let me know how you solved it these issues if that have same behavior written in this thread, it might help to gain some insight.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [August 18, 2022, 5:28am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/3 "2022-08-18T05:28:10Z")

</div>

Thank you for sharing your findings in relation to the ENVIRONMENT\_IS\_NODE variable- we do not explicitly test FMOD on Node, I have added a task to investigate this in more detail.  
In 2.02.07 we started handling the user interaction internally; would it be possible for you to try updating and see if that gets around the user interaction requirement?

---

<div class="post-metadata">

**Author:** ![creta5164](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creta5164/32/1757_2.png) [@creta5164](https://qa.fmod.com/u/creta5164)\
**Post date:** [August 18, 2022, 9:50am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/4 "2022-08-18T09:50:03Z")

</div>

Hello jeff.

I tried version 2.02.08, still needs a fix to force it to be a web environment, but now I’ve confirmed that it works fine in NW.js without requiring any user interaction!

Thanks for the quick update just for this.

---

<div class="post-metadata">

**Author:** ![creta5164](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creta5164/32/1757_2.png) [@creta5164](https://qa.fmod.com/u/creta5164)\
**Post date:** [August 31, 2022, 2:32am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/5 "2022-08-31T02:32:50Z")

</div>

Hello, sorry for reopening this thread.

In the lower version of NW.js (tested on 0.29.4), I found that audio came out without user interaction, but in the newest version of NW.js (tested on 0.66.1), I found that there was no audio until user interaction.

Is there has a solution for this?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [September 7, 2022, 12:53am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/6 "2022-09-07T00:53:20Z")

</div>

Are you getting any console errors before interacting with the screen? We are adding listeners to the click and touchend events internally to resume audio, all things I assume are supported by the latest version of NW.js. Can you try calling `OutputAudioWorklet_resumeAudio()` from your code manually and see if that helps at all?

---

<div class="post-metadata">

**Author:** ![creta5164](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creta5164/32/1757_2.png) [@creta5164](https://qa.fmod.com/u/creta5164)\
**Post date:** [September 7, 2022, 1:23am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/7 "2022-09-07T01:23:18Z")

</div>

Hello, Jeff!

I just confirmed this issue, no notifications popped up on the console.  
And like you said, I tried `OutputAudioWorklet_resumeAudio()`.  
Then FMOD start working fine with the log : `Resetting audio driver based on user input.`  
Is it ok to use this function?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [September 7, 2022, 1:37am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/8 "2022-09-07T01:37:43Z")

</div>

Thank you for confirming- we should be calling this function for you, the fact that it isn’t being called inidcates a possible fault with our setting of event listeners in NW.js.  
I will update the Dev team with this information for their investigations with Node/NW.js. In the meantime it should be fine to call this method yourself.

---

<div class="post-metadata">

**Author:** ![creta5164](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creta5164/32/1757_2.png) [@creta5164](https://qa.fmod.com/u/creta5164)\
**Post date:** [September 7, 2022, 1:51am UTC](https://qa.fmod.com/t/problem-with-html5-build-on-nw-js/19116/9 "2022-09-07T01:51:40Z")

</div>

I really didn’t know there was a problem on the NW.js side.

Thank you for checking it out, Jeff!
