Coder Social home page Coder Social logo

marcusbelcher / android-getusermedia-test Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 11.0 131 KB

Simple Android application which tests JavaScript getUserMedia access from inside a web app viewed from a WebView

License: MIT License

Java 100.00%
android getusermedia webview javascript webrtc java camera webrtc-demos

android-getusermedia-test's Introduction

README

This repo is a simple test case for anyone to use - as is - to check JavaScript WebRTC / Camera access via getUserMedia inside a WebView in an Android application. The Application - as default - views another test application I have hosted on GitHub pages:(https://github.com/marcusbelcher/wasm-asm-camera-webgl-test).

The key learnings from this is that you make sure you:

  • Have the hardware permissions inside of the AndroidManifiest.xml
  • Get runtime permission acceptance
  • Handle the Chrome WebView permissions at runtime
  • Use the WebRTC adapter.js
  • Serve any websites with HTTPS, and if inside of an iframe make sure you allow camera access.

Build

  • Checkout this repo
  • Open with Android Studio 3.0.1
  • Connect an actual device (couldnt get it working in an emulator)
  • Build to actual device
  • Enable permissions
  • Run app

3rd Parties

Issues encountered

  • Java Versions: API 21, Androud Studio 3+, WebRTC dependency requires Graddle build settings to have the following to allow API level 21 to 26.
    compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 }
  • WebRTC / getUserMedia access: Min API version of 21, this is for runtime onPermissionRequest

Useful links

android-getusermedia-test's People

Contributors

marcusbelcher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

android-getusermedia-test's Issues

failed to connect camera

error 09-10 16:12:10.525 24093-24275/com.example.marcusbelcher.getusermediatest E/cr_VideoCapture: allocate: Camera.open: java.lang.RuntimeException: Fail to connect to camera service
09-10 16:12:10.530 24093-24275/com.example.marcusbelcher.getusermediatest E/cr_VideoCapture: stopCaptureAndBlockUntilStopped: mCamera is null
09-10 16:12:26.639 24093-24275/com.example.marcusbelcher.getusermediatest E/cr_VideoCapture: allocate: Camera.open: java.lang.RuntimeException: Fail to connect to camera service
09-10 16:12:26.642 24093-24275/com.example.marcusbelcher.getusermediatest E/cr_VideoCapture: stopCaptureAndBlockUntilStopped: mCamera is null

in app: tests
Camera: Failed, an error occured and did not inject camera feed into webpage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.