endmr11 / ed_screen_recorder

Screen recorder plugin for Flutter. Supports IOS and Android devices.
MIT License
26 stars 36 forks source link

Screen Recorder is not working, if we enable the Audio #20

Open hemandroid opened 2 years ago

hemandroid commented 2 years ago

Screen recording is not working, if we enable the audio as true. Please check the logs and provide the fix asap.

E/Video Error:(12058): java.lang.RuntimeException: setAudioSource failed.
E/Video Error:(12058):  at android.media.MediaRecorder.setAudioSource(Native Method)
E/Video Error:(12058):  at com.hbisoft.hbrecorder.ScreenRecordService.initRecorder(ScreenRecordService.java:485)
E/Video Error:(12058):  at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:245)
E/Video Error:(12058):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4639)
E/Video Error:(12058):  at android.app.ActivityThread.access$2000(ActivityThread.java:247)
E/Video Error:(12058):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
E/Video Error:(12058):  at android.os.Handler.dispatchMessage(Handler.java:106)
E/Video Error:(12058):  at android.os.Looper.loopOnce(Looper.java:201)
E/Video Error:(12058):  at android.os.Looper.loop(Looper.java:288)
E/Video Error:(12058):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/Video Error:(12058):  at java.lang.reflect.Method.invoke(Native Method)
E/Video Error:(12058):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/Video Error:(12058):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/Video Error:(12058): java.lang.IllegalStateException: failed to get surface
E/Video Error:(12058):  at android.media.MediaRecorder.getSurface(Native Method)
E/Video Error:(12058):  at com.hbisoft.hbrecorder.ScreenRecordService.initVirtualDisplay(ScreenRecordService.java:545)
E/Video Error:(12058):  at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:269)
E/Video Error:(12058):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4639)
E/Video Error:(12058):  at android.app.ActivityThread.access$2000(ActivityThread.java:247)
E/Video Error:(12058):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
E/Video Error:(12058):  at android.os.Handler.dispatchMessage(Handler.java:106)
E/Video Error:(12058):  at android.os.Looper.loopOnce(Looper.java:201)
E/Video Error:(12058):  at android.os.Looper.loop(Looper.java:288)
E/Video Error:(12058):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/Video Error:(12058):  at java.lang.reflect.Method.invoke(Native Method)
E/Video Error:(12058):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/Video Error:(12058):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/Video Error:(12058): java.lang.IllegalStateException
E/Video Error:(12058):  at android.media.MediaRecorder.start(Native Method)
E/Video Error:(12058):  at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:315)
E/Video Error:(12058):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4639)
E/Video Error:(12058):  at android.app.ActivityThread.access$2000(ActivityThread.java:247)
E/Video Error:(12058):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
E/Video Error:(12058):  at android.os.Handler.dispatchMessage(Handler.java:106)
E/Video Error:(12058):  at android.os.Looper.loopOnce(Looper.java:201)
E/Video Error:(12058):  at android.os.Looper.loop(Looper.java:288)
E/Video Error:(12058):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/Video Error:(12058):  at java.lang.reflect.Method.invoke(Native Method)
E/Video Error:(12058):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/Video Error:(12058):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

@endmr11

NehilKoshiya commented 2 years ago

Add this to your pubspec.yaml to get microphone permission permission_handler: ^10.0.1

And request permission before start recording

await Permission.microphone.request();

Cevocey commented 1 year ago

Can you show us where to apply in the code?

endmr11 commented 1 year ago

Version 0.0.13 has been released. Could you please check again and report back to me?