3

I'm developing a WebKit-based mac application: a native Cocoa app that consists mostly of a WebView. The app needs to play audio and do simple DSP. I'd like to use the Web Audio API for this.

When I open a Web Inspector on my WebView, I'm told that window has a property calledwebkitAudioContext, but this property is set to undefined.

> window
[...]
webkitAudioContext: undefined
[...]

This suggests that the Web Audio API isn't supported in WebViews by default. Is there a way to enable it?

Are WebKit feature flags involved somehow?

Community
  • 1
  • 1
dB'
  • 7,838
  • 15
  • 58
  • 101

5 Answers5

2

I researched this issue on the Apple Developer forums. One poster there had the exact same question, but he didn't get a response. If no one on the Apple Forums knows how to enable Web Audio, I'm going to conclude that it can't be done, at least for the moment. What a shame.

I think the answer to my question is "no".

If this changes in the future, or if you have any evidence to the contrary, please correct me.

dB'
  • 7,838
  • 15
  • 58
  • 101
1

For OS X 10.10 development only this thing was running for me:

Terminal:

defaults write com.domain.myappid WebKitWebAudioEnabled -bool YES

Hans Maier
  • 11
  • 1
0

Did you try this with Mavericks? Also did you try this: http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html

0

Yes, here's how to enable it:

WebPreferences* p = [webView preferences];

if ([p respondsToSelector:@selector(setWebAudioEnabled:)]) {
    [p setWebAudioEnabled:YES];
}
  • Huh. When I try this code I get warnings and errors related to the selector 'setWebAudioEnabled:' not being defined. And, indeed, when I look in `WebPreferences.h` I don't see any flags related to WebAudio. I'm on 10.8, but my development target is set to 10.9. Am I doing something wrong? – dB' Nov 30 '13 at 20:15
0

This is working for me: [webPrefs setWebAudioEnabled:YES];

Prashant Kumar
  • 20,069
  • 14
  • 47
  • 63
Kelton Turvey
  • 71
  • 1
  • 2