How to solve “NotAllowedError: play() can only be initiated by a user gesture.” audio problem in javascript android webview?

While playing audio in javascript using webview in android platform we may encounter following problem NotAllowedError: play() can only be initiated by a user gesture.. This is due to security and good user experience issue. So to enable sound play we should use following code in android:

Android SDK below 17 will not support this hack so we should use the condition.

Please comment if this worked for you. Thanks.

About the Author

has written 35 stories on this site.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!


Copyright © 2020 Programmer to Programmer- A website for web programming and mobile application programming tutorials.
Wordpress themes