endmr11 / ed_screen_recorder

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

Audio doesn't work with Android. #76

Closed jdevp closed 1 year ago

jdevp commented 1 year ago

Please update the package: EdScreenRecorderPlugin.java uses or overrides a deprecated API. Note: Recompile with-Xlint:deprecation for details.

Also, it doesn't record audio with Android.

E/MediaRecorder(10143): SurfaceMediaSource could not be initialized!
E/MediaRecorder(10143): start called in an invalid state: 32
E/Video Error:(10143): java.lang.RuntimeException: setAudioSource failed.
E/Video Error:(10143):  at android.media.MediaRecorder.setAudioSource(Native Method)
endmr11 commented 1 year ago

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

jdevp commented 1 year ago

Thank you very much for continuing to work on it. It is only working Flutter package that can do screen capture. I'll test it and let you know.  By the way, is there a way to prevent the popup window of "Starting recording or casting..." every time the app tries to record the screen? On Sunday, April 30, 2023 at 10:36:36 AM EDT, Eren Demir @.***> wrote:

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

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

endmr11 commented 1 year ago

Sorry, I have no idea about that. But I will examine.

jdevp commented 1 year ago

I just tested the new version. The popup window is gone.(Thanks). However, I don't see the video is saved in the gallery, either without sound or with sound. Based on your sample, it is supposed to save to the gallery if dirPathToSave is undefined. static Future<Map<String, dynamic>?> startRecord( {required String fileName}) async { var response = await edScreenRecorder?.startRecordScreen( fileName: fileName, // dirPathToSave Optional. It will save the video there when you give the file path with whatever you want. //If you leave it blank, the Android operating system will save it to the gallery. //dirPathToSave: , audioEnable: false, ); //setState(() { _response = response; return _response!; }

On Sunday, April 30, 2023 at 10:57:50 AM EDT, Eren Demir ***@***.***> wrote:  

Sorry, I have no idea about that. But I will examine.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

Hi, have you successfully generated video in the gallery with the new version?  I don't see anything is generated with the new version. At least I can generate a video without sound witht he old version. On Sunday, April 30, 2023 at 11:30:27 AM EDT, Jay Huang @.***> wrote:

I just tested the new version. The popup window is gone.(Thanks). However, I don't see the video is saved in the gallery, either without sound or with sound. Based on your sample, it is supposed to save to the gallery if dirPathToSave is undefined. static Future<Map<String, dynamic>?> startRecord( {required String fileName}) async { var response = await edScreenRecorder?.startRecordScreen( fileName: fileName, // dirPathToSave Optional. It will save the video there when you give the file path with whatever you want. //If you leave it blank, the Android operating system will save it to the gallery. //dirPathToSave: , audioEnable: false, ); //setState(() { _response = response; return _response!; }

On Sunday, April 30, 2023 at 10:57:50 AM EDT, Eren Demir ***@***.***> wrote:  

Sorry, I have no idea about that. But I will examine.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

endmr11 commented 1 year ago

Saves the current record to the path given by path_provider. But if you want to save it to the gallery, I can offer a solution, you can copy the file anywhere you want with any sharing package, as a result, this plugin returns the saved path after the recording is finished.

jdevp commented 1 year ago

This release is not working for me. I tried to save it to a temporary directory and then copy to gallery but video is generated. It seems that the plugin hung at stop recording, nothing printed with 'response'. I'm curious if you have tested and was able to record a video with this release. static Future stopRecord() async { print("recording is stop"); var response = await edScreenRecorder?.stopRecord(); // print("recording is stop"); print(response); _response = response; Directory tempDir = await getTemporaryDirectory(); String tempPath = tempDir.path; await saveVideo("$tempPath/test.mp4"); }

On Sunday, April 30, 2023 at 01:39:16 PM EDT, Eren Demir ***@***.***> wrote:  

Saves the current record to the path given by path_provider. But if you want to save it to the gallery, I can offer a solution, you can copy the file anywhere you want with any sharing package, as a result, this plugin returns the saved path after the recording is finished.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

endmr11 commented 1 year ago

Of course, I was able to record and I was able to both save to the folder I wanted and share it successfully thanks to the sharing plugin. Can you please try and use this plugin => share_plus

jdevp commented 1 year ago

Thanks for confirming. I'm not sure what is wrong with my environment. The code simply hangs at  stopRecord statement so no video file is generated. static Future stopRecord() async {    print("recording is stop");    var response = await edScreenRecorder?.stopRecord();    print("recording is stop 2"); // this line doesn't print out

On Sunday, April 30, 2023 at 07:56:59 PM EDT, Eren Demir ***@***.***> wrote:  

Of course, I was able to record and I was able to both save to the folder I wanted and share it successfully thanks to the sharing plugin. Can you please try and use this plugin => share_plus

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

I download your example and it shows the following popup every time I start recording but it work.

In my app, I don't see this popup window anymore with the new version but it doesn't work. In the od version, it shows this window. The question is why I don't see this window popup with the new version ?

On Sunday, April 30, 2023 at 07:56:59 PM EDT, Eren Demir ***@***.***> wrote:  

Of course, I was able to record and I was able to both save to the folder I wanted and share it successfully thanks to the sharing plugin. Can you please try and use this plugin => share_plus

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

I see the problem. Even with your example, I have to click on 'Start Record' button 3 times in order to get the popup window from MediaProjectionManager popup window. The old version, I only need to call startRecord once, then the MediaProjectionManager pops up. I'm going to open a new issue for this problem.

On Monday, May 1, 2023 at 10:36:49 AM EDT, Jay Huang ***@***.***> wrote:  

I download your example and it shows the following popup every time I start recording but it work.

In my app, I don't see this popup window anymore with the new version but it doesn't work. In the od version, it shows this window. The question is why I don't see this window popup with the new version ?

On Sunday, April 30, 2023 at 07:56:59 PM EDT, Eren Demir ***@***.***> wrote:  

Of course, I was able to record and I was able to both save to the folder I wanted and share it successfully thanks to the sharing plugin. Can you please try and use this plugin => share_plus

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

endmr11 commented 1 year ago

This is not a problem, if you have already taken the permissions from the user before taking the screen recording, it will be a better user experience, otherwise the plugin will take the permissions one by one.

jdevp commented 1 year ago

I have moved the first 2 permission requests (record audio, access photos) prior to clicking on the record button.  However, it still requires 2 clicks on the record button in order to bring up the ProjectionManager popup window. While with the old version, it only requires one click before the ProjectionManager popup is displayed.  So, the old version has better user experience.  On Monday, May 1, 2023 at 01:46:59 PM EDT, Eren Demir @.***> wrote:

This is not a problem, if you have already taken the permissions from the user before taking the screen recording, it will be a better user experience, otherwise the plugin will take the permissions one by one.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

Hi Eren, Thanks again for the nice work. The sound works with Android. However, I have discovered the following 2 issues although the second might not be an issue with the plugin.

  1. The 'stopRecord()' method takes a very long time to respond and finally gives out a message ' A resource failed to call release' although it does stop the recording.
  2. I have permission requests (audio record and photo/media) permission at the startup of my app so technically the 'ProjectionManager' popup window should displayed when I call 'startRecord()' the first time.  But the 'ProjectionManager' window only occurs when I made a second call to 'startRecord()'.  I'm not sure if this is the plugin issue because my explicit request for 'Permission.photos' always returns 'denied'. I researched and it seems to be a bug with Permission_Handler package.  Maybe because of the Permission.photos issue, I have to call 'startRecord' twice.  This becomes an issue with my app since users don't know that they have to clickthe start record button twice to start the recording for the first time. If you know a workaround, please let me know. Thanks.

    On Monday, May 1, 2023 at 01:46:59 PM EDT, Eren Demir @.***> wrote:

This is not a problem, if you have already taken the permissions from the user before taking the screen recording, it will be a better user experience, otherwise the plugin will take the permissions one by one.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

Hi Eren, I'm still having the issue that the following screen doesn't show up until the `startRecord' is called twice when the first time user runs the app. I did find a work around for the issue although it would be nice to fix the problem. The second issue is that the following warning pops up every time I try to record screen instead of once when app starts. I don't know if there is a way to avoid that from the plugin. (Suppress the popup if it already showed at app startup).

On Wednesday, May 3, 2023 at 03:37:23 PM EDT, Jay Huang ***@***.***> wrote:  

Hi Eren, Thanks again for the nice work. The sound works with Android. However, I have discovered the following 2 issues although the second might not be an issue with the plugin.

  1. The 'stopRecord()' method takes a very long time to respond and finally gives out a message ' A resource failed to call release' although it does stop the recording.
  2. I have permission requests (audio record and photo/media) permission at the startup of my app so technically the 'ProjectionManager' popup window should displayed when I call 'startRecord()' the first time.  But the 'ProjectionManager' window only occurs when I made a second call to 'startRecord()'.  I'm not sure if this is the plugin issue because my explicit request for 'Permission.photos' always returns 'denied'. I researched and it seems to be a bug with Permission_Handler package.  Maybe because of the Permission.photos issue, I have to call 'startRecord' twice.  This becomes an issue with my app since users don't know that they have to clickthe start record button twice to start the recording for the first time. If you know a workaround, please let me know. Thanks.

    On Monday, May 1, 2023 at 01:46:59 PM EDT, Eren Demir @.***> wrote:

This is not a problem, if you have already taken the permissions from the user before taking the screen recording, it will be a better user experience, otherwise the plugin will take the permissions one by one.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

Hi Eren, how do I get a return code if user clicks on cancel' button? It seems thatstartRecord` never returns when user clicks a cancel button.

On Thursday, May 18, 2023 at 09:44:33 AM EDT, Jay Huang ***@***.***> wrote:  

Hi Eren, I'm still having the issue that the following screen doesn't show up until the `startRecord' is called twice when the first time user runs the app. I did find a work around for the issue although it would be nice to fix the problem. The second issue is that the following warning pops up every time I try to record screen instead of once when app starts. I don't know if there is a way to avoid that from the plugin. (Suppress the popup if it already showed at app startup).

On Wednesday, May 3, 2023 at 03:37:23 PM EDT, Jay Huang ***@***.***> wrote:  

Hi Eren, Thanks again for the nice work. The sound works with Android. However, I have discovered the following 2 issues although the second might not be an issue with the plugin.

  1. The 'stopRecord()' method takes a very long time to respond and finally gives out a message ' A resource failed to call release' although it does stop the recording.
  2. I have permission requests (audio record and photo/media) permission at the startup of my app so technically the 'ProjectionManager' popup window should displayed when I call 'startRecord()' the first time.  But the 'ProjectionManager' window only occurs when I made a second call to 'startRecord()'.  I'm not sure if this is the plugin issue because my explicit request for 'Permission.photos' always returns 'denied'. I researched and it seems to be a bug with Permission_Handler package.  Maybe because of the Permission.photos issue, I have to call 'startRecord' twice.  This becomes an issue with my app since users don't know that they have to clickthe start record button twice to start the recording for the first time. If you know a workaround, please let me know. Thanks.

    On Monday, May 1, 2023 at 01:46:59 PM EDT, Eren Demir @.***> wrote:

This is not a problem, if you have already taken the permissions from the user before taking the screen recording, it will be a better user experience, otherwise the plugin will take the permissions one by one.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

jdevp commented 1 year ago

Here is a link on how to prevent this popup dialog every time, only once when app starts. Hopefully, you can incorporate it into your next release. 

Mediaprojection issues on Android 9+

|

Mediaprojection issues on Android 9+

I made an OCR application that makes a screenshot using Android mediaprojection and processes the text in this i... |

|

|

On Saturday, May 20, 2023 at 11:06:57 AM EDT, Jay Huang ***@***.***> wrote:  

Hi Eren, how do I get a return code if user clicks on cancel' button? It seems thatstartRecord` never returns when user clicks a cancel button.

On Thursday, May 18, 2023 at 09:44:33 AM EDT, Jay Huang ***@***.***> wrote:  

Hi Eren, I'm still having the issue that the following screen doesn't show up until the `startRecord' is called twice when the first time user runs the app. I did find a work around for the issue although it would be nice to fix the problem. The second issue is that the following warning pops up every time I try to record screen instead of once when app starts. I don't know if there is a way to avoid that from the plugin. (Suppress the popup if it already showed at app startup).

On Wednesday, May 3, 2023 at 03:37:23 PM EDT, Jay Huang ***@***.***> wrote:  

Hi Eren, Thanks again for the nice work. The sound works with Android. However, I have discovered the following 2 issues although the second might not be an issue with the plugin.

  1. The 'stopRecord()' method takes a very long time to respond and finally gives out a message ' A resource failed to call release' although it does stop the recording.
  2. I have permission requests (audio record and photo/media) permission at the startup of my app so technically the 'ProjectionManager' popup window should displayed when I call 'startRecord()' the first time.  But the 'ProjectionManager' window only occurs when I made a second call to 'startRecord()'.  I'm not sure if this is the plugin issue because my explicit request for 'Permission.photos' always returns 'denied'. I researched and it seems to be a bug with Permission_Handler package.  Maybe because of the Permission.photos issue, I have to call 'startRecord' twice.  This becomes an issue with my app since users don't know that they have to clickthe start record button twice to start the recording for the first time. If you know a workaround, please let me know. Thanks.

    On Monday, May 1, 2023 at 01:46:59 PM EDT, Eren Demir @.***> wrote:

This is not a problem, if you have already taken the permissions from the user before taking the screen recording, it will be a better user experience, otherwise the plugin will take the permissions one by one.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>