react-native-screcorder icon indicating copy to clipboard operation
react-native-screcorder copied to clipboard

Only honoring the initial camera view styles

Open Benmidi opened this issue 8 years ago • 10 comments

We're running into an issue where we have a small version of the camera in an initial component. To let people know that we're going to be recording their response. When we transition to the next component even though we supply a different set of dimensions in the styles the camera renders with the previously specified styles.

Bee Tee Dubz - Awesome job on the library!

Benmidi avatar Sep 01 '15 14:09 Benmidi

Hey ben, Are you sure that you rerender your component correctly after applying the new dimensions in your style ? I didn't have much time recently but I'm going to spend some time to improve this module, lot of work ! If you find any solution to fix a bug, PR are welcomed

maxs15 avatar Sep 01 '15 20:09 maxs15

We're definitely re-rendering. The recorder is being required into two separate components with entirely different states and styles. To get around the issue (in our tight timeline) we're using both your component and react-native-camera. I hope to take more time to figure out the underlying reasons and to add saveToCamera (when I do, I'll submit a PR.)

Benmidi avatar Sep 04 '15 16:09 Benmidi

Oh, just found the issue. It's because of the view init function. It returns any previously initialized view. We removed the if statement and we were able to get the styles to work. Not sure if this introduces a memory issue, it's probably better to use the existing one and somehow change the bounds whenever it's called subsequently.

https://github.com/maxs15/react-native-screcorder/blob/master/ios/RNRecorderManager.m#L24-L31

Benmidi avatar Sep 04 '15 17:09 Benmidi

You're right ! I'm gonna have to do some tests, will submit a PR soon.

maxs15 avatar Sep 08 '15 15:09 maxs15

@maxs15 Thanks for this awesome lib! Is this PR still coming?

edit: Would be perfect to initialise the camera upfront and show it later (in a different place) instantaneously (and destroy it via method too)! At the moment it takes quite a'lot of time to initialise (especially if you changed the camera from back to front last time)

ms88privat avatar Nov 12 '15 02:11 ms88privat

Sorry, totally forgot about it. Did it solve the issue for you by removing the if statement in the view method ? I doesn't solve the problem on my side

maxs15 avatar Nov 12 '15 15:11 maxs15

@maxs15 I did not change my view styles, so I don't know about that. But it will not re-render my sub-components anymore. Before that, all my sub-components (e.g. segmentBar, controls, ..) got duplicated.

Please have a look at my new issue also. Thanks :+1:

ms88privat avatar Nov 12 '15 16:11 ms88privat

I don't get it why this behaves so differently on the first appearance?

I changed this code

// Alloc UI element
if (_recorderView == nil) {
    _recorderView = [[RNRecorder alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
}
return _recorderView;

to this code (to handle multiple videos etc., which is working great with this version!):

_recorderView = nil;
_recorderView = [[RNRecorder alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
return _recorderView;

But now the big problem is that I have to transition two times to the same record view before I can save my recorded video.... (see issue https://github.com/maxs15/react-native-screcorder/issues/9)

Anyone have an Idea?

ms88privat avatar Nov 12 '15 20:11 ms88privat

@maxs15 any news here?

I can not write Objective-C. I would really like to know, why I have to render the RecorderComponent two times, before I am able to save the recorded video.

Also your actual implementation (without my "fix" above), does not allow to record multiple videos and save them in different files (but it can save the Video on the first time RecorderComponent appears...)

Thank you!

ms88privat avatar Dec 10 '15 19:12 ms88privat

It appears that there is some issues with SCRecorder when creating multiple instances, no news for now I currently don't have much time to investigate this issue.. Why couldn't you save multiple files ? I don't know exactly what you want to do, but when the video is saved you'll get an url to the file. After that, it's your job to do whatever you want with it, you could upload it or copy it somewhere in the filesystem with a plugin like react-native-fs

maxs15 avatar Dec 11 '15 16:12 maxs15