React-native sound delay issue - react-native

This is just general question. I want to make drums-like app but i have sound delay. Maybe someone tried some other package(s) and did some magic, I used react-native-sound and react-native-video since they are most popular and not outdated like others. This is code sample:
new Sound(`${filename}.mp3`, Sound.MAIN_BUNDLE, error => {
if (error) {
return;
} else {
audio.play(() => {
audio.release();
});
}
});
There are other libraries, maybe outdated, but i am looking for any input to make it better, we did handler with onPressIn to make it slightly faster but still big delay:
<TouchableOpacity onPressIn={handleOpenPress}>
If this fails I will try to make another library, but I fear it will have the same delay. For some reason this repo works very fast: https://github.com/dwicao/react-native-drum-kit. I used same code and made even a list with prepared sounds to be used like soundList[i++ % 10].play() but still no effect.

Related

expo.sqlite high memory usage when creating to many transactions at a close interval

I am using expo-sqlite for my application and encounter an odd problem.
I have a ``ScrollViewand I want to save the scroll position too the db and so I am doing it inonScrollEndDrag`
The issue is that as time gets by say 3 to 4 hours, I see a memory increase in the app Info.
it goes to 1GB+ sometimes. Is that normal?
I am using expo-sqlite-wrapper Which I do not believe that the issue originate from there.
You can look at its code here as I am the author of the library, I could make change and fix it if there is an issue.
Here is the code for save operation, it really as simple as savechange() and Save() operation in the link above.
onScrollBeginDrag={() => {
clearTimeout(onScrollTimeout.current);
scrollable.current = true;
}}
onScrollEndDrag={({ nativeEvent }) => {
clearTimeout(onScrollTimeout.current);
onScrollTimeout.current = setTimeout(() => {
scrollable.current = false;
if (nContext.state.currentChapterSettings && nContext.state.currentChapterSettings.savechanges && !nContext.state.viewPlayer)
nContext.state.currentChapterSettings.savechanges();
}, 1500);
if (!nContext.state.viewPlayer)
setContentOffset(nativeEvent.contentOffset);
}}
onScroll={({ nativeEvent }) => {
if (!nContext.state.viewPlayer && scrollable.current) {
onScroll(nativeEvent);
}
}}
Is it maybe accessing the database to often is wrong or is it really alright as the sqlite takes care of the memory issue when its full?
Could anyone please explained how SQLite really handle the memory, as I may not understanding this right and this behavior is really alright.

How to use 3rd party camera app with Ionic React Capacitor

Well the point is the following:
import {
Camera,
CameraResultType,
CameraSource,
Photo,
} from "#capacitor/camera";
export function usePhotoGallery() {
// import { usePhotoGallery } from "../hooks/usePhotoGallery"; per usarlo in esterna
const scatta = async () => {
const cameraPhoto = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Camera,
quality: 100,
});
};
return {
scatta,
};
}
With this pretty basic code just calls the default camera and makes it take a shot.
It's working fine no problem. The issue comes in, by my case, by the fact that i have a custom ROM with no pre-installed camera. So no default camera. I know pretty much no one would have my issue. But I'd like to cover those 0.1% of user that will have this problem.
So, finally, how can I can use a 3rd party camera app? Or just create one if it's better.
For example I can take photos from Whatsapp, Instagram, Snapchat ecc. I guess cuz they have their own camera. So the point basically is:
How can I make the user select the app he prefers for thake the shot (like the pop-up that ask "open with *choiches*.."
If i can't do the previous option, then how can I do my own camera?
Sorry for my probably disgusting english

sharing image, link and title using react-native-share not working

I am using react-native-share to share content accross different social platform. For plain text it is working fine. But when I include image + message(contains link) + title, then it is not working.
Here is the code which I am using to do so:
let imagePath = null;
RNFetchBlob.config({
fileCache: true,
})
.fetch('GET', FILE_URL)
.then((resp) => {
imagePath = resp.path();
return resp.readFile('base64');
})
.then(async (base64Str) => {
const content = `Sharing Link ${link}`;
const base64Data = `data:image/jpeg;base64,${base64Str}`;
const shareOption = {
message:content,
url: base64Data,
title: 'This is title',
type: 'image/jpeg',
};
await Share.open(shareOption);
return RNFetchBlob.fs.unlink(imagePath);
});
} catch (error) {
console.error(error);
}
I tried different variations of it, what I found on SO and on other links. But non of them worked.
What I've tried and didn't worked:
Sharing URL of images instead of base64 - Only image is shared, message got removed. And in whats app image link is not converted to image.
by removing message key and only passing url. (In this way image is getting shared. But it has no relevance. Because I am not able to set any kind of message or link)
I am not sure what I am missing here.
This is an interesting project. I have to admit up front, this is a bit of a non-answer. I apologize for that, but I wanted to let you know what I found because it seemed more useful to share my research rather than just keep it in my head and it was too big for a comment.
So I took a look at the github issues for this project to see if your issue was documented. There are 93 open issues and a lot of people complaining about varieties of things that don't work the way you would think in combination of these variables (message, base64) especially on iOS. Have you taken a look at their issue log to see if you can find better detail? Are you using iOS?
Here's a few that seem to be left open that complain about almost the exact issue you posted about. Some offer workarounds. Some lead to dead-ends. If you haven't read these, it would behoove you to get up to speed. If you do know all this, maybe I'll just leave this post up for posterity if others come across it.
https://github.com/react-native-share/react-native-share/issues/760
https://github.com/react-native-share/react-native-share/issues/966
https://github.com/react-native-share/react-native-share/issues/831
https://github.com/react-native-share/react-native-share/issues/1025

dragAndDrop using webdriverio

I have tried every single thing to perform dragAndDrop using webdriverio but nothing works. I have also posted a question in the webdriverio gitter but no response. below posted code is one of the ways I tried and its supposed to work but it just doesn't!
` await this.driver.moveToObject(source);
await sleep(2000);
await this.driver.buttonDown(0);
await sleep(2000);
await this.driver.moveToObject(destination);
await sleep(2000);
await this.driver.buttonUp(0);`
I'm not sure what properties are on the source and destination objects you are using but here is an example of how I was able to get it to work using the same commands you are trying.
In my example I have a table with columns that can be re-ordered by dragging and dropping them wherever I want them to be. First I get the two column headers I want to switch
let docIdHeader = browser.element('div[colid="documentid1"]');
let pageCountHeader = browser.element('div[colid="_PAGE_COUNT1"]');
If I log these objects out to the console I can see the properties stored in them.
> docIdHeader
{ sessionId: 'e35ae3e81f1bcf95bbc09f120bfb36ae',
value:
{ ELEMENT: '0.3568346822568915-1',
'element-6066-11e4-a52e-4f735466cecf': '0.3568346822568915-1' },
selector: 'div[colid="documentid1"]',
_status: 0 }
> pageCountHeader
{ sessionId: 'e35ae3e81f1bcf95bbc09f120bfb36ae',
value:
{ ELEMENT: '0.3568346822568915-2',
'element-6066-11e4-a52e-4f735466cecf': '0.3568346822568915-2' },
selector: 'div[colid="_PAGE_COUNT1"]',
_status: 0 }
Now using the same technique you are using and the selector property off of these objects I can get it to work in two ways.
browser.dragAndDrop(docIdHeader.selector, pageCountHeader.selector);
Or
browser.moveToObject(docIdHeader.selector)
browser.buttonDown(0)
browser.moveToObject(pageCountHeader.selector)
browser.buttonUp(0)
I ran this in the REPL interface so I know it works as I could see each step being executed after I sent the commands. If you are not familiar with how to use the REPL I highly recommend learning. You can play around with commands in the console until you figure something out and then add those commands to your tests.
Also, as I stated in my comments above. dragAndDrop() and moveToObject() are going to be deprecated soon and you will likely see a lot of warnings about it when you use these. The correct way to implement a drag and drop action going forward is to use browser.actions(). Unfortunately, I don't have an example of how to do it that way as I haven't played with it yet. If no one provides an example by tonight I will try to get one together for you.
Even I faced this issue wherein the cursor doesn't move to the destination object after buttonDown and using moveToObject twice worked for me.
await this.driver.moveToObject(source);
await this.driver.buttonDown(0);
await this.driver.moveToObject(destination);
await this.driver.moveToObject(destination);
await this.driver.buttonUp(0);

What is the current `map()` doing?

( Gun.version 0.9.6 )
Given the following data structure
{
lights:{
1:{
state:{
on:true,
color:'red',
br:254
}
},
2:{
state:{
on:true,
color:'red',
br:254
}
},
3:{
state:{
on:true,
color:'red',
br:254
}
}
}
}
I want to turn the lights on/off at the same time.
gun.get('lights').val(cb) does give me {1:{...},2:{...},3:{...}} and gun.get('lights').path('1.state.on').put(false); works perfect.
I thought that by doing gun.get('lights').map().path('1.state.on').put(false) it would 'map' over all lights but instead it only changes the first light.
Question: How do i turn on/off all the lights ?
#stef-de-vries , you've spotted an important TODO bug in gun's source code!
Currently (v0.9.6), put does not work with map() commands. I think it only picks the first item (which may be random) and then turns it off.
This is bad, and needs to be addressed.
For now, the work around is to probably do something like:
gun.get('lights').map().path('state.on').val(function(){
this.put(false);
});
Which is ugly.
Hmm.. okay, but it fails on gun.get('lights').map().val(cb) also if i run it the second time.
Solved my problem with the each() module
gun.get('lights').each(node=>{
gun.get(node._['#']).path('state.on').put(true)
})