I'm trying to find a way to record the screen of the application and more specifically the WebView activity inside the app.
I've done some researches and people suggested using MediaProjectionManager or MediaRecorder APIs for that but I'm not very sure which one and how to implement it.
I looked at some examples and the MediaProjection only record what's in a SurfaceView.. but mine is a Webview, would it still works? Any suggestion would be appreciated.
Thanks!
I looked at some examples and the MediaProjection only record what's in a SurfaceView
No. An app using the media projection APIs does not have to have a SurfaceView at all. For example, this sample app captures a screencast, and it does not have a SurfaceView. The media projection APIs capture what is on the screen. This could be your app or other apps that are on the screen at the time that you are recording.
but mine is a Webview, would it still works?
In general, yes, bearing in mind that you are recording what is on the screen, so if another application appears (e.g., an incoming phone call), you will be recording that other application. The media projection APIs do not record a View, they record the screen.
One possible limitation with the media projection APIs would be DRM. It is possible that you will not be able to record everything, because some views are showing DRM-protected content (e.g., playing back a movie), and that might not get captured. I have not played with the media projection APIs in this situation to see how they behave.
Related
I am trying to do following functionality in my mobile app:
1) In my app I have record button. When pressed it starts camera recording
2) if I have music playing in my mobile phone in any of
players - this music should overlay the video
3) External microphone
in this situation should also record additional sound
So as a result we will have video record+music+microphone sound
Right now, I got stuck while trying to get access to android.permission.CAPTURE_AUDIO_OUTPUT
(I am not using root access btw and can't use it)
Is there a way to solve 1+2+3(record+music+microphone) ? If yes, how can one solve it?
Not really an answer, but too long for a comment.
Guess you should take a look at MediaRecorder here and the android.permission.RECORD_AUDIO permission. But MediaRecorder is only working with MediaPlayer. So if you are using Exoplayer or similar it's not a solution. Be aware, that this might not work on all hardware devices and with all Android Versions (I think you should test with Android 10 first)!
Be aware of AudioFocusManager on Android. If you start the camera, it will request the AudioFocus, so other music apps on your device will stop playing music if you request the camera with sound. (There are differences between Android 10 and below).
Furthermore, camera is using device microphone, so I think recording microphone and camera input at the same time might not work, but you can always use the video-sound in this case.
I am playing streaming in vlc player and using surfaceView to show streaming, Now, i want to take screenshot of streaming at any time.
Problem
Now problem is that we can not take screenshot of SurfaceView. I also saw a sample of Media Projection but it's asking for permission every time. So on pause method of activity is called every time, Which should not be.
Can Any one help me on this,
Is there any Xml tag which replace SurfaceView to take screenshot or we can remove the permission to capture screen using Media Projection.
Does anyone know how should I use the class MediaRecorder to record the activity of the phone screen? That is, instead of taking a static snapshot, I want to capture it as a video. I know that the camera API starts the process of encoding the video and so on, but i wonder if there is a way to make it see the very screen of the device as the "camera". Thanks for any help.
i wonder if there is a way to make it see the very screen of the device as the "camera"
No.
But, on Android 5.0+ devices, you can use the media projection APIs to record a screencast. See this sample project.
I need some way to record android screen AND audio. I have seen some libraries that record screen, but I need audio too. Does such a thing exists? Anybody knows any library to do that? I know something similar is available for iOS (ReplayKit), but seems that is not available for Android. Any alternative for Android?
The only thing in the Android SDK that allows you to record the screen are the media projection APIs. They do not include sound. However, there is nothing stopping you from recording sound yourself and attempting to merge the two. The problem is in getting the audio to accurately sync up with the video.
You can try looking into https://github.com/saki4510t/ScreenRecordingSample.
It does record the screen's video and audio from the microphone.
Is there some api or method to know if some video is playing on android platform?
I want to stop some background job when a video is playing at foreground.
The api or method had better comes from surfaceflinger, window manager service etc. framework modules.
Thanks.
The SurfaceFlinger process can know that it is receiving frames at a consistent rate, but it can't know if it's a video or just app animation.
The mediaserver process is responsible for managing the hardware video decoders. It can know if a video is being decoded, but it can't know if the video is being displayed. It won't be involved if the app is using a custom software-only decoder.
There isn't an unequivocal way to detect that a video is being played and presented on the display.