I'm building a web app using Agora.io. I'd like to be able to switch from the front-facing to the rear-facing camera on a client's smartphone. I've seen agora docs for switchCamera. I've tried the following:
switchCamera();
myAgoraClient.switchCamera();
localStream.switchCamera();
All of them throw a no such function error.
What is the correct way to switch the camera in agora.io for web?
You can do this with switchDevice method in 2.5 SDK
switchDevice(type: string, deviceId: string, onSuccess: function,
onFailure: function): void
For example;
localStream.switchDevice("video", "<deviceid>", console.log,console.log)
Should do the work. I was trying same thing but examples contains old 2.4 js sdk, you need to specifically download ^2.5
I don't think the latest version of Agora Web SDK have these methods out of box.
However, you can create a camera list through:
AgoraRTC.getDevices(function(devices){
cameras = devices.filter(device => device.kind === 'videoinput');
});
Then give switchCamera an implementation:
function switchCamera(){
cameraIndex = (++cameraIndex) % cameras.length;
}
Use cameras[cameraIndex].deviceId as cameraId to create a new local video stream and publish it out.
Related
I have been facing an issue regarding Geolocation in iOS/Android app. I am using Titanium Js and have upgraded Ti v7.5.0 to v8.3.1. I checked my legacy code and came to know that this below function
Titanium.Geolocation.setFrequency()
creating a problem. It seems like this function gets deprecated.
this.locationFrequency = 100;
Geolocate.prototype.getCurrentPosition = function(callback){
var self = this;
// initialize the callback
this.locationReceivedCallback = callback;
// Set this so we get updates rapidly
Titanium.Geolocation.setFrequency(this.locationFrequency)
// Register for the actual event
Titanium.Geolocation.addEventListener('location', someCallBackFunc);
};
Now, I need help to understand what actually this Titanium.Geolocation.setFrequency() does. Is there any alternate way to achieve the same in latest version of Ti?
Since it is open source you can look at the github repo:
https://github.com/appcelerator/titanium_mobile/blob/7_5_X/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/GeolocationModule.java#L469
and check the official documentation at frequency
https://docs.appcelerator.com/platform/latest/?print=/api/Titanium.Geolocation#property-frequency and use the recommendation there.
I am working with Expo, React Native and I want to to be able to detect text from images. Is there an package i can work with to achieve this?
I am using Expo camera module to snap the picture and supply the URI to the text detector
I have tried using react-native-text-detector but I am getting the error that the function detectFromUri is not defined. I have also tried with tesserect.js but it fails on import with "unable to resolve variable location".
await this.camera.takePictureAsync(options).then(photo => {
photo.exif.Orientation = 1;
//console.log(photo.uri);
const visionResp = await RNTextDetector.detectFromUri(photo.uri);
if (!(visionResp && visionResp.length > 0)) {
throw "UNMATCHED";
}
console.log(visionResp);
});
I am expecting the visionResp to log the results returned from the detection but instead i get undefined is not an object (evaluating '_reactNativeTextDetector.default.detectFromUri')
Is your project created with expo-cli?
If yes, Expo is not supporting OCR currently. There is a feature request on canny.io but you can't know for sure when it will become available.
Your only choice is to use an OCR service like this one.Internet connectivity will be required.
If not, (and the project is created with react-native-cli) you should be able to successfully use react-native-text-detector. Just make sure you link the package correctly. Docs here
I tried with the npm module react-native-check-app-install but I couldn't achieved always the result is false.
Also tried with react-native-installed-apps to get the list of apps installed in the phone but this return always empty list.
Did you make sure to declare the URL schemes?
https://developers.google.com/maps/documentation/ios-sdk/start#step_6_declare_the_url_schemes_used_by_the_api
Once you've done that, you don't need an additional package to check if you can open Google Maps. You can just use the Linking module.
Linking.canOpenURL('comgooglemaps://?center=40.765819,-73.975866')
.then((canOpen) => {
if (canOpen) { console.log('open google maps'); } else { console.log('open apple maps'); }
});
Is it possible using the web extensions API to get the default download folder for the current profile? I need to send it via native messaging to an external app.
I feel like https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads should have it but it does't seem to.
Your best bet is probably making a dummy download and sending the "filename" property that you get back as a variable to your external app.
You would use the browser.downloads.onChanged event to get a reference to the filename value:
browser.downloads.onChanged.addListener(listener);
function listener(changed){
if(changed.filename != null){
// Do something
// Remove downloads.onChanged listener
browser.downloads.onChanged.removeListener(listener);
}
}
browser.downloads.download({url: dummyUrl});
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads/onChanged
I'm writing a small audio recorder component in Silverlight 4. It works fine, but I've noticed that when I'm recording audio, the light on my webcam turns on indicating that the camera is active.
While I know that I'm not doing anything insidious with the webcam, my users would have every right to be suspicious. Is it possible to tell Silverlight that I'm only interested in microphone access and not activate the webcam?
FWIW here's how I'm accessing the mic:
private CaptureSource _source = new CaptureSource();
private MemoryAudioSink _sink; // Inherits from AudioSink. Doesn't do much more
// than store PCM audio stream in memory
private void Record_Click(object sender, RoutedEventArgs e)
{
if (( CaptureDeviceConfiguration.AllowedDeviceAccess ||
CaptureDeviceConfiguration.RequestDeviceAccess() ) &&
_source.State == CaptureState.Stopped)
{
_sink = new MemoryAudioSink();
_sink.CaptureSource = _source;
_source.Start();
}
}
CaptureSource will frequently grab the default video input device, even if you don't tell it to. Though you aren't using the camera, Silverlight is indeed accessing it. Hopefully, MS will fix this odd behavior in a later version of Silverlight.
In the meantime, just explicitly set VideoCaptureDevice to null:
var _audioCaptureSource = new CaptureSource {VideoCaptureDevice = null};
This would depend on the webcam driver - Silverlight would have no control over this.
I'm guessing its related to your use of CaptureSource. Microsoft's web site claims that:
Silverlight 4 APIs only use
CaptureSource in a video scenario
where audio may not be relevant.
Is there a way to get audio without creating your own CaptureSource?