maxs15 / react-native-screcorder

A <Recorder /> element for react-native
233 stars 56 forks source link

Only honoring the initial camera view styles #7

Open Benmidi opened 9 years ago

Benmidi commented 9 years ago

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!

maxs15 commented 9 years ago

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

Benmidi commented 9 years ago

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 commented 9 years ago

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

maxs15 commented 9 years ago

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

ms88privat commented 8 years ago

@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)

maxs15 commented 8 years ago

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

ms88privat commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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!

maxs15 commented 8 years ago

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