mobile-packages icon indicating copy to clipboard operation
mobile-packages copied to clipboard

On Android/Chrome using camera failed with : Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.

Open Rebolon opened this issue 10 years ago • 3 comments

Hi,

i try to use the camera on smartphone (android + chrome) and since few days i always have :

Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture. 

If i look at the package, the play() action is done on Template rendered, maybe it's the problem because the action is not triggered by user.

To reproduce:

  • just add the mdg:camera
  • render the template "camera" using {{> camera}} in your layout
  • start an nginx as a proxy with SSL (because getUserMedia no more works without SSL)
  • start meteor app
  • open Chrome on your Android device
  • fill the url of your computer
  • The video stream is not displayed, but you only have a photo

Rebolon avatar Feb 01 '16 14:02 Rebolon

just added a Pull Request (PR13) that solve problems on Android Chrome

Rebolon avatar Feb 01 '16 15:02 Rebolon

In lieu of this PR being accepted, it looks like adding the following code to your app will hotfix the issue:

Template.viewfinder.onRendered(function() {
  this.$("#video").attr("autoplay", "autoplay");
});

Primigenus avatar Mar 29 '16 12:03 Primigenus

It seems to be a valid solution. Actually i use my own solution in my own fork of this pakages stored in /packages/mobile-packages folder.

Rebolon avatar Mar 29 '16 14:03 Rebolon