Audio on pre 5.0 android

  • 1
  • Question
  • Updated 4 years ago
html5 Audio works on Android 5.1 not on 4.4.4.
cli-5.2.0
using the following js to start the sound.
new Audio(sounds/sound.mp3).play()
Any help would be appreciated.
Photo of Nate McClenahan

Nate McClenahan

  • 2 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Chris Griffith

Chris Griffith, Champion

  • 347 Posts
  • 92 Reply Likes
You are going to need to look at the Cordova Media Plugin for audio playback on older Android platforms.

See: https://www.npmjs.com/package/cordova...
Photo of Nate McClenahan

Nate McClenahan

  • 2 Posts
  • 0 Reply Likes
Ok, That sounds good.

Also while i was playing around, I found an alternate workaround.
I changed from using audio files to using 64bit encoded audio, and it works fine.

Do you know why the base64 encoded audio works better?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
The source is different.
KitKat's webview doesn't play Audio objects when the file is in the local assets. It plays files from SD card fine.

However, the Media plugin would be the most universal solution.