We have a video player application that using ExoPlayer2. And its needs to be protected from the screen recorder.
We integrated the 'WindowManager.LayoutParams.FLAG_SECURE' but some of the device is not supporting this feature ( Lenovo , Samsung etc ..) in ExoPlayer2 activity screen ,user can capture full video through 'DU Recorder'.
This is happening only ExoPlayer2 activity all other screens are working fine
If you're using a SurfaceView with ExopPlayer2, you can use SurfaceView.setSecure(true) which will prevent the player from being recorded.
If you're not already using a SurfaceView, you can set one on the SimpleExoPlayer - you can see how that works by checking out this SO post. Or if you're interacting with Exo through something other than SimpleExoPlayer, then I'd bet there's a way to get access to the SurfaceView to call setSecure on it.
Let me know if that works or if you need any further clarification.
Related
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.
A question like this is already posted but in my situation, there is some difference.
I have different layout design for landscape and portrait modes (both modes have VideoView) of the fragment that's why I can not use configChanges as below:
android:configChanges="screenSize|orientation|keyboardHidden"
Now when I rotate everything recreate.
I tried retainState/saveInstanceState but does not get success.
I want my video to play continuously without stopping like YouTube app.
Any help would be appreciated.
If you are using the MediaPlayer classes for video playback I would suggest against doing so. YouTube app uses a library called ExoPlayer that is far superior in terms of video support on Android devices. It is a little harder to get setup and operating but once it is that success in playing videos across all the android devices is much better.
That being said. You will still need to stop the video and resume playing at that specific time frame. The best way to do this would be to get the timestamp on rotation and once the surface being played to is ready again (onSurfaceCreateed or onSurfaceChanged events if using the ExoPlayer library) start the video again at that time stamp.
I've an app that uses a Native Activity as it is mostly C++ code (cross platform).
I also need to play Video and Audio so have another Activity that uses MediaPlayer to play video and/or audio. This is used in conjunction with the Native Activity to play Video in front of the OpenGL rendered application.
The MediaPlayer activity is based upon that in the ApiDemos example, and works fine on MOST devices (Nexus 7/10, Galaxy S3/Tab2, even some low-cost devices like Fusion5).
BUT running it on a low-cost Scroll Plus 7" tablet - the code functions, but no Video is displayed.
The Audio plays, the Video Controls show and are usable.
NOTE: I have actually been able to hack with the code to get the Video showing - though this is not a solution it may help someone identify the problem.
In my Native Code where the Open Gl render calls eglSwapBuffers, if I comment this line out the Video shows. (I complete the rendering in a loop inside android_main)
Obviously this means my OpenGL Rendering that needs to go on in the background stops working, so I cannot fix it this way.
Device:
Scroll Plus
7" TABLET by Storage Options
Jelly Bean 4.1
From LogCat i believe it is running a CedarX-based Media Decoder/Renderer.
After 4 days on this issue, I've finally found out that the Video was being drawn BEHIND my OpenGL. Why only on this device I don't know. All the other aspects of the Video Activity (the controls etc) are in front where it should be.
The eglSwapBuffers was a red-herring, in that case I was not drawing anything to the screen.
I want to make video player with next option to keep playing video after rotate device.
I created service with MediaPlayer and set SurfaceHolder of SurfaceView after rotate sceen. It works only for Android 4.x. For Android 2.3.X after replace second call setDisplay user doesn't see video, but hears sound of video.
Could you give me direction or example how to implement this option at custom player?
PS. Player shows streaming video.
Okay, I've found solution. It's so easy. I set configChanges="orientation|screenSize" for activity with custom player. In this case activity won't be recreated after rotate device it's changed on the same instance.
As result, I don't need service for keeping MediaPlayer and don't need replace SurfaceHolder.
I would like to add one video to the main screen of my application but I want to user to be able to do other things in the app meanwhile. Think about some video animation or flash movie for some website that you can watch the video and look on other things in the website.
lets say I have buttons and more things in the same screen and I want a small video to be playing there too in a loop.
is this possible?
I thought that Flash movie could be good for that, but its only for latest versions of android then I don't want to use it.
Thanks.
You can just use the VideoView.