Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaRecorder prepare failed on Android #13

Closed
kenle opened this issue Apr 1, 2020 · 2 comments
Closed

MediaRecorder prepare failed on Android #13

kenle opened this issue Apr 1, 2020 · 2 comments

Comments

@kenle
Copy link

kenle commented Apr 1, 2020

Hi, I'm having trouble getting this plugin to work on Android devices.

I get the error below, I believe related to the output file. I'm no Android expert, and hours of search on Google about MediaRecorder, getExternalStoragePublicDirectory, and setOutpuFile gives me no clearer clue as to why this is happening. So just want to ask, anything come to mind why this error may occur?

Screen Shot 2020-04-02 at 02 11 16

My device information:
Samsung Galaxy Tab A (2019)
Android 9 (API 28)

I've also used permission_handler plugin to request permission for external storage.

Thank you very much.

@kenle
Copy link
Author

kenle commented Apr 2, 2020

It is resolved. In case anyone else runs into problems with Android, I give a quick run through of the modifications I made to get it working. Sorry these are screenshots and not links to the actual code lines.

The following modifications were made in file FlutterScreenRecordingPlugin.kt

  1. The original mDisplayWidth and mDisplayHeight were causing MediaRecorder to fail for some reason, I modified as follows.
    image

  2. I found I had to edit Activity.Compat.startActivityForResult to use registrar.activity(), else I was getting a null exception error with the current code.

image

  1. Finally, I had to modify declaration of late init variable _result, else I was also getting a null exception error.

image

@salime45
Copy link
Member

salime45 commented Apr 4, 2020

Thanks

@salime45 salime45 closed this as completed Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants