javascript - Android WebView - Switching between cameras: Working in browsers (Firefox and Chrome) but not working in WebView - OnChange issue? -


i developing android video app using webrtc , add ability change front camera. practice functionality used website: https://simpl.info/getusermedia/sources/ , amended code can switch between camera using browser working on chrome , firefox on android not work on webview - show stream front camera when opened first not update camera when change selection camera.

does know solution or workaround this? onchange not working in android webview? (i have searched cant find solution)

i hope not stupid question, complete noob android development.

my html:

<!doctype html>   <html lang="en">   <head>     <script src="main.js"></script>      <base target="_blank">     <title>video test</title>    </head>   <body>     <p>this test</p>     <div id="container">       <div class="select">         <label for="videosource">video source: </label><select id="videosource"></select>       </div>       <video muted autoplay></video>     </div>   </body> </html> 

my javascript (main.js):

'use strict';  var videoelement = document.queryselector('video'); var videoselect = document.queryselector('select#videosource');  navigator.mediadevices.enumeratedevices()     .then(gotdevices).then(getstream).catch(handleerror);  videoselect.onchange = getstream;     function gotdevices(deviceinfos) {   (var = 0; !== deviceinfos.length; ++i) {     var deviceinfo = deviceinfos[i];     //this creates element can used later     var option = document.createelement('option');     //this sets value of option id of device     option.value = deviceinfo.deviceid;     if(deviceinfo.kind === 'videoinput') {     option.text = deviceinfo.label || 'camera' + (videoselect.length + 1);     videoselect.appendchild(option);   } else {       console.log('found 1 other kind of source/device: ', deviceinfo);     }      }  }  function getstream() {   if (window.stream) {     window.stream.gettracks().foreach(function(track) {       track.stop();     });   }    var constraints = {     video: {       optional: [{         sourceid: videoselect.value       }]     }   };    navigator.mediadevices.getusermedia(constraints).       then(gotstream).catch(handleerror); }  function gotstream(stream) {   window.stream = stream; // make stream available console   videoelement.srcobject = stream; }  function handleerror(error) {   console.log('error: ', error); } 

my permissions (there more there needs be)

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="uk.co.babyvideolink.babyvideolink1">     <!--added 20/07 cb-->      <uses-permission android:name="android.permission.internet"/>     <uses-permission android:name="android.permission.access_network_state"/>     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.record_audio" />     <uses-permission android:name="android.permission.camera" />     <uses-permission android:name="android.permission.modify_audio_settings" /> <uses-permission android:name="android.permission.capture_secure_video_output" />     <uses-permission android:name="android.permission.capture_video_output" />     <uses-permission android:name="android.permission.capture_audio_output" />     <uses-feature android:name="android.hardware.camera.autofocus" android:required="true" />     <uses-feature android:name="android.hardware.camera.front" android:required="true" />     <uses-feature android:name="android.hardware.camera.level.full" android:required="true" />     <uses-feature android:name="android.hardware.camera.capability.raw" android:required="true" />     <uses-feature android:name="android.hardware.camera.any" android:required="true" />     <uses-feature android:name="android.hardware.microphone" android:required="true" />     <uses-feature android:name="android.hardware.camera2" android:required="true" />     <uses-feature android:name="android.hardware.camera" android:required="true" /> 

please note copyright notices have been removed code brevity.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -