-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Support for WebAudioPlugin on PhoneGap-Apps #37
Conversation
This is great! Thanks for the pull. We will test it out, and integrate it shortly. |
Hi, thanks for this helpful post. Part of our future plans is better support for other platforms like PhoneGap. One problem we have with your current solution is that it will disable local testing on mobile devices. Although this seems an unlikely scenario, we'd prefer a PhoneGap specific solution. Some quick searching lead us to a couple of solutions. Specifically it seemed like one of the following would work:
We don't currently have experience with PhoneGap, so we were wondering what you thought. Will any of these address the issue you were having, and if so which do you think is best? We really appreciate any feedback you can give us. Thanks. |
So the only solution that I can think of right now is via the
The current status of the WebAudioPlugin is disabled for ANY local execution/testing, my solution does enable local execution/testing on mobile devices. (or did I mix something up here?) |
Thanks for the follow up. Sorry, I should have been more clear. The WebAudioPlugin disables itself locally to allow for local testing of files (usually by allowing SoundJS to default to HTMLAudioPlugin). So, for example, you can use toolkit to output a project and pop it open in Chrome and have it work, without having to use a local web server. This scenario is unlikely on current mobile devices, but we try not add limits when possible. Does that make sense? Perhaps a different approach, detecting if XHR is available? Although you say web audio does not require XHR when used through phonegap? Do you have any thoughts on this? |
Now I got you :) - that does make sense! When packaging assets with an application(like in PhoneGap), they will be called through the local-file:// protocol and the thing is that WebView-applications(like PhoneGap) are sandboxed, that's why "local" files will cause no cross-domain issue and that's why the WebAudio-Plugin will just work fine with "file://" through PhoneGap. One "solution"(that only works on iOS though...) would be to detect if the environment is a WebView or the Mobile Browser, like here for iOS. But the User-Agents for Android the Android WebView seem to be almost identical (depending on some devices and version numbers) (see here). I did quite some research and the only solution that made sense to me was to check for ios/android in the user-agent, because without that, both, the WebAudioPlugin and the HTMLAudioPlugin weren't working when i packaged the app with PhoneGap. |
Thanks a lot for your feedback it's been very helpful in figuring this out. We've decided to implement your solution as it seems more likely code would be running inside a PhoneGap app then locally on mobile devices. Just a side note, HTMLAudioPlugin is disabled on iOS devices by default because of the limits of the system. You can read details in the documentation. |
Glad I could be of some help to you :) |
We have pushed support for local files, so I am going to close this for now. Please feel free to respond or re-open if issues persist. |
In PhoneGap Apps the
location.protocol
equals'file:'
, however the Web Audio does not require XHR if used through PhoneGap, so I added an additional Line to check if this is a Mobile device.Note
I did ONLY test this on an iPad since I do not have any other devices for testing.