B4A Library [B4A] [B4XPages] ScreenRecorder/ScreenShots

B4A B4XPages ScreenRecorder - version 0.7 (25/09/2016)

25/01/2021 - Updated the sample app to use SDK29, foreground services, and also wrote it as a B4XPages app. There are no changes to the library.


Here is a wrapper/library which lets you record the screen and save it as a video file.

It is using MediaProjection which is available from API 21 (Lollipop) and will not work on earlier versions of Android.

It is based on this Github-project. Kudos to the original author.

See next post for events and methods.

I am attaching a sample project along with the library.

Edit: The free version posted here is OK for screen-recording. There is also a more advanced version of this library which enables screen-recording with audio, capturing screenshots and screen-mirroring. Send me a PM (start a conversation) if you are interested.

Some basic stuff to remember:
1) you need at least Lollipop to get this to work. The library uses MediaProjection which was introduced with SDK 21.
2) You cannot use it for a spy-app. When users run your app and the code in your app which triggers the screen-capturing (recording or screenshots), users have to give permission.
3) some apps, such as Telegram, can block MediaProjection, and thus capturing/recording of the screen is not possible.


Please remember that creating libraries and maintaining them takes time and so does supporting them. Please consider a donation if you use my free libraries as this will surely help to keep me motivated. Thank you!
 

Attachments

  • B4AScreenRecorderLibs.zip
    7.9 KB · Views: 1,089
  • B4XPagesScreenRecorder.zip
    12.5 KB · Views: 384
Last edited:

artemis

Member
Licensed User
Oh that's fantastic to hear! Thank you very much for the update. Can't wait to give it a whirl!
 

artemis

Member
Licensed User
Hi Moster, It's been a while, I hope everything is well. Do you have a status update on your library by any chance? I'm really looking forward to it.
 

Yvon Steinthal

Active Member
Licensed User
No word on this? Im having a weird error :

java.lang.IllegalStateException: Can't stop due to wrong state.
at android.media.MediaMuxer.stop(MediaMuxer.java:228)
at net.yrom.screenrecorder.ScreenRecorder.release(ScreenRecorder.java:194)
at net.yrom.screenrecorder.ScreenRecorder.run(ScreenRecorder.java:94)


EDIT: It was permission related... all is good and working
 
Last edited:

Yvon Steinthal

Active Member
Licensed User
Any way to change the video quality that is created? I seem to have very high quality videos, but i send those files to a server...
 

moster67

Expert
Licensed User
Any way to change the video quality that is created? I seem to have very high quality videos, but i send those files to a server...
In the version I posted, the only way you can reduce the size is by lowering the resolution of your videos.

I take this occasion to give an update (users have asked):
I have already developed a more advanced version of the wrapper which permits screenrecording with audio plus taking screenshots. In this version, you can set various parameters such as bitrate which permits you to reduce the video-quality and thus getting less "heavy" recordings.
I meant to publish it some time ago but I got busy building my new home-recording studio and lately I have rather been recording music than programming.
I trust to release this more advanced wrapper in the beginning of January (after the holidays) if I find some time.

An alternative way to reducing the size of the final screenrecordings will be by using my B4A FFMpegencoder wrapper. Also this wrapper, finished long time ago and already in use by some of my beta-testers, is still to be released. Hope to do that in the beginning of January too.
 

MarcoRome

Expert
Licensed User
Goodmoorning Mike and Merry Christmas ( again ;) ). It is possible to run the same in a service ?
I have tried, but not by any error of fact the event is not raise.
Great library as usualy
 

moster67

Expert
Licensed User
Is it running on a service?
It is possible to run the same in a service ?

As you can see from the demo-app, you must call GetPermission and this uses OnActivityResult. You could use a transparent activity and show some views initially. Then when you have received OK from user, you hide the views. You can handle user-inputs (such as stop recording) through notifications or even listening to shaking events...
 

artemis

Member
Licensed User
Hi Moster, when do you think you will be able to post the updated version of the library with the screenshot/bmp access capability?

Thanks buddy!
 

moster67

Expert
Licensed User
After some input from two users, I came up with a solution to take screenshots continuously. I combined this with Erel's sample project MJPEG/CCTV Server and created a small project which demonstrates how one can create a screen-mirroring app with the advanced version of this library and B4A and show the android screen in a web-browser. I am using a compress-rate of 40 and FPS = 20. The quality looks quite good in my opinion.

See for yourselves in this video:


This demo/sample app is included in the paid version.
 
Last edited:
Top