yutasuzuki / react-native-record-screen

react-native-record-screen
MIT License
143 stars 38 forks source link

Recording Not Working #11

Open Jeyavijay opened 3 years ago

Jeyavijay commented 3 years ago

Hi,

OS Version - iOS 12.2 iPhone 6s

I have installed the package and the pod file

getting the error on Xcode

These errors I'm getting if I restart the mobile

Can you please help me to make the recorder work?

Thanks in Advance

yutasuzuki commented 3 years ago

@Jeyavijay I haven't been able to investigate it thoroughly yet, but maybe it won't launch on iOS 12.2.

https://stackoverflow.com/questions/54325221/replaykit-error-code-5807-recording-interrupted-by-multitasking-and-content

Jeyavijay commented 3 years ago

Thanks let me update the OS version and check it out and will let you know if any support needed else I will close the issue.

Jeyavijay commented 3 years ago

@yutasuzuki

In iOS 14.1 the recording is working

In Android getting this error while starting the recording

I/System.out: startRecording
I/System.out: resultCode
    -1
    AppCompatActivity.RESULT_OK
I/System.out: -1
E/MediaRecorder: SurfaceMediaSource could not be initialized!
    start called in an invalid state: 0
I/System.out: HBRecorderOnError
    errorCode
    100
    reason
    java.lang.RuntimeException: setAudioSource failed.
        at android.media.MediaRecorder.setAudioSource(Native Method)
        at com.hbisoft.hbrecorder.ScreenRecordService.initRecorder(ScreenRecordService.java:432)
        at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:211)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
        at android.app.ActivityThread.access$1600(ActivityThread.java:199)
I/System.out:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/System.out: HBRecorderOnError
    errorCode
    100
    reason

I have added all permission files on Manifest.xml

Thanks in Advance

yutasuzuki commented 3 years ago

@Jeyavijay Maybe buildToolsVersion of build.gradle(Project: your App) is old. Please change over 30.0.2.

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 26
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    ...
}
Jeyavijay commented 3 years ago

Hi I have changed the build tool version from 29.0.2 to 30.0.2 and still having the same error.

Here is my full log after the recording started

I/System.out: clean
W/VideoCapabilities: Unrecognized profile 4 for video/hevc
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
I/System.out: startRecording
I/System.out: resultCode
    -1
    AppCompatActivity.RESULT_OK
    -1
E/MediaRecorder: SurfaceMediaSource could not be initialized!
E/MediaRecorder: start called in an invalid state: 0
I/System.out: HBRecorderOnError
I/System.out: errorCode
    100
    reason
    java.lang.RuntimeException: setAudioSource failed.
        at android.media.MediaRecorder.setAudioSource(Native Method)
        at com.hbisoft.hbrecorder.ScreenRecordService.initRecorder(ScreenRecordService.java:432)
        at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:211)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
        at android.app.ActivityThread.access$1600(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/System.out: HBRecorderOnError
    errorCode
    100
    reason
    java.lang.IllegalStateException: failed to get surface
        at android.media.MediaRecorder.getSurface(Native Method)
I/System.out:     at com.hbisoft.hbrecorder.ScreenRecordService.initVirtualDisplay(ScreenRecordService.java:488)
        at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:235)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
        at android.app.ActivityThread.access$1600(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/System.out: HBRecorderOnError
    errorCode
    100
    reason
    java.lang.IllegalStateException
        at android.media.MediaRecorder.start(Native Method)
        at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:260)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
I/System.out:     at android.app.ActivityThread.access$1600(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
D/EGL_emulation: eglMakeCurrent: 0xdbcba200: ver 3 0 (tinfo 0xdc22e360)
I/chatty: uid=10086(com.sampledemo) RenderThread identical 2 lines
D/EGL_emulation: eglMakeCurrent: 0xdbcba200: ver 3 0 (tinfo 0xdc22e360)
D/EGL_emulation: eglMakeCurrent: 0xdbcba200: ver 3 0 (tinfo 0xdc22e360)

Thanks in Advance

yutasuzuki commented 3 years ago

@Jeyavijay
"setAudioSource failed," it says. Try setting mic to false. I don't know what's causing it, but it seems to be failing to get the Microphone.

https://github.com/yutasuzuki/react-native-record-screen#setting-microphone

Also, go to your device's settings and make sure the app's permissions are allowed.

Jeyavijay commented 3 years ago

@yutasuzuki I have changed the mic to false but still the same error throwing once recording started, also I have checked the permissions and enabled on the settings before the start of the recording

Here is my code

  startRecording = async () => {
    RecordScreen.clean();

    await RecordScreen.startRecording({mic: false}).catch((error) => {
      alert(error);
      // setRecording(false);
      // setUri('');
    });
    alert('done starting');
  };

  stopRecording = async () => {
    const res = await RecordScreen.stopRecording().catch((error) =>
      alert('error---', error),
    );

    if (res) {
      const url = res.result.outputURL;
      alert(JSON.stringify(res));
    }
  };
}
Jeyavijay commented 3 years ago

Hi @yutasuzuki any update on the previous one?

yutasuzuki commented 3 years ago

@Jeyavijay I'm sorry. I don't know any more. Android uses HBRecorder, so you may have the same thing in the HBRecorder Issues. https://github.com/HBiSoft/HBRecorder/issues

Jeyavijay commented 3 years ago

@yutasuzuki Hi - Recording is now working on Android but on different device. I think its related to device. But now the problem is the recorded video is full of black. Can you help me out on this.

Thanks in advance ![Uploading Screen Shot 2020-11-25 at 7.23.56 PM.png…]()

Jeyavijay commented 3 years ago

@yutasuzuki Hi - any update on this?

MehulBhatt45 commented 3 years ago

Hello @yutasuzuki I have implemented this module, Its working fine in Android devices. But in iOS devices it records only the application screen. If I send my application to background mode, it supposed to record the home screen but its not recording it.

Please help. Thank you in advance.

dguard commented 2 years ago

@yutasuzuki Had same issue I played on Android with different SDK versions and with gradle distributionUrl, now it works :)