1

I'm creating a webserver on RPI3 that will display the status of the baby(Lying Down, Sitting, Out of the Crib). It will also play a sound notification once the status is "Out of the Crib".

The javasript of my webserver is this:

function notif() {

var pos = $('.status').text();
var audio = new Audio('alarm.mp3');

if(pos == "Out of the crib") {
audio.play();
}

This code is working fine when I access my webserver in different laptop. But when I view my webserver in android webview it does not play the sound, but in different laptop it's working.

Should I do something on my java file in android studio or android webview does not support this kind of thing?

But I tried to add button in my webserver that will play the sound once it's click. And I open it again in my webview and it's working I dont know what to do. Please help. Thank you.

1 Answers1

0

I'm sorry to say but this is a feature not a bug. This is done on purpose to prevent developers from forcing the user to hear/see things without user interaction.

The only thing that you are allowed is to play a muted video without user interaction.

You can override this but only on your device. See this question and the several answers that might help you.

Itamar Kerbel
  • 2,290
  • 1
  • 17
  • 27