Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getUserMedia working on website but not working on mobile

I am using getusermedia to record audio in my website. I've included the javascript of getusermedia. The record function works fine on website but doesn't even popup for permission in when opened on mobile.

var constraints = {
  audio: true,
  video: false
}
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
  permissiongiven = 1;
});

this is the sample code which prompt me for permission but doesn't work on mobile. How can I make it work on both device. Any help is appreciated. Thanks.

Edit :- The code is now working fine on mobile as well. Maybe it was solved from chrome updates or security certificates of website. Thanks all for help.

like image 637
shubham kakade Avatar asked Mar 05 '23 18:03

shubham kakade


2 Answers

Note that on mobile devices, you have to use SSL to use getUserMedia(). Check out if you're accessing your website with a http:// prefix. Try change it to https:// and it should work fine.

like image 95
Juntong Chen Avatar answered Apr 08 '23 21:04

Juntong Chen


I found this website useful in answering this question

https://caniuse.com/#search=getusermedia

It says getUserMedia only supported from Chrome for Android version 70 (released Oct 16 2018)

like image 27
Hassan Voyeau Avatar answered Apr 08 '23 22:04

Hassan Voyeau