Isvisoft / flutter_screen_recording

A new Flutter plugin for record the screen.
MIT License
142 stars 138 forks source link

Record screen with Audio is not working #65

Closed Lix-ai closed 1 year ago

Lix-ai commented 3 years ago

Hi, The Record screen audio always failed with: " I/System.out( 2065): Error onMethodCall startRecordScreen I/System.out( 2065): null "

" I/flutter ( 2065): Foreground on Started E/MediaRecorder( 2065): setAudioSource called in an invalid state(4) I/System.out( 2065): Error onMethodCall startRecordScreen I/System.out( 2065): null I/flutter ( 2065): Foreground on Started I/System.out( 2065): 1280 720 I/System.out( 2065): file --- /storage/emulated/0/DCIM/Title.mp4 D/AndroidRuntime( 2065): Shutting down VM E/AndroidRuntime( 2065): FATAL EXCEPTION: main E/AndroidRuntime( 2065): Process: com.example.flutterthe_a_app, PID: 2065 E/AndroidRuntime( 2065): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=333, result=-1, data=Intent { (has extras) }} to activity {com.example.flutterthe_a_app/com.example.flutterthe_a_app.MainActivity}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION E/AndroidRuntime( 2065): at android.app.ActivityThread.deliverResults(ActivityThread.java:5015) E/AndroidRuntime( 2065): at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056) E/AndroidRuntime( 2065): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) E/AndroidRuntime( 2065): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime( 2065): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime( 2065): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) E/AndroidRuntime( 2065): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime( 2065): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime( 2065): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime( 2065): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 2065): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime( 2065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/AndroidRuntime( 2065): Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION E/AndroidRuntime( 2065): at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) E/AndroidRuntime( 2065): at android.os.Parcel.createException(Parcel.java:2357) E/AndroidRuntime( 2065): at android.os.Parcel.readException(Parcel.java:2340) E/AndroidRuntime( 2065): at android.os.Parcel.readException(Parcel.java:2282) E/AndroidRuntime( 2065): at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231) E/AndroidRuntime( 2065): at android.media.projection.MediaProjection.(MediaProjection.java:59) E/AndroidRuntime( 2065): at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:119) E/AndroidRuntime( 2065): at com.isvisoft.flutter_screen_recording.FlutterScreenRecordingPlugin.onActivityResult(FlutterScreenRecordingPlugin.kt:66) E/AndroidRuntime( 2065): at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:691) E/AndroidRuntime( 2065): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:378) E/AndroidRuntime( 2065): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:625) E/AndroidRuntime( 2065): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:583) E/AndroidRuntime( 2065): at android.app.Activity.dispatchActivityResult(Activity.java:8305) E/AndroidRuntime( 2065): at android.app.ActivityThread.deliverResults(ActivityThread.java:5008) E/AndroidRuntime( 2065): ... 11 more E/AndroidRuntime( 2065): Caused by: android.os.RemoteException: Remote stack trace: E/AndroidRuntime( 2065): at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:479) E/AndroidRuntime( 2065): at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135) E/AndroidRuntime( 2065): at android.os.Binder.execTransactInternal(Binder.java:1154) E/AndroidRuntime( 2065): at android.os.Binder.execTransact(Binder.java:1123) E/AndroidRuntime( 2065): I/Process ( 2065): Sending signal. PID: 2065 SIG: 9 Lost connection to device. "

I did all the things you required, and have to use 0.4.0 (old foreground service) version as your dependencies request.

Using also minSdkVersion of 29 AND targetSdkVersion of 29 AND audioplayers plugin version 0.16.0

==> At the end when flutter and dart SDK and all other plugins upgraded, what will be this plugin, is it going to be maintained?

Thanks in advance for the effort and plugin :)!

jeghedderchristoffer commented 3 years ago

Having same problem

syednajamabbasnaqvi commented 3 years ago

I've fixed all the issues in this plugin and updated code on both IOS/Android. Using it myself right now in a project. If you want i can fork this and create a new Repo. What do ya say?

Lix-ai commented 3 years ago

If you fix it, sure, why not :)

ZeeshanSalem commented 2 years ago

I've fixed all the issues in this plugin and updated code on both IOS/Android. Using it myself right now in a project. If you want i can fork this and create a new Repo. What do ya say?

I need this cope as well kindly provide me

deepak-ariceum commented 2 years ago

I've fixed all the issues in this plugin and updated code on both IOS/Android. Using it myself right now in a project. If you want i can fork this and create a new Repo. What do ya say?

Bro, did you do this? Then please share the link to the repo, will use. Thank you!

deepak-ariceum commented 2 years ago

Please use this instead, works perfectly! https://github.com/endmr11/ed_screen_recorder

salime45 commented 1 year ago

Fix