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.
Related
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.
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 am trying to build a media player in android which will play http streams, I have customized the https://github.com/commonsguy/vidtry player for my needs, now only one issue remains, during playback, if user receives phone call, the video player should store the current position and resume it after call, I have managed to do it, but after phone call all I can hear is audio, no video is shown, I know it has something to do with SurfaceHolder.Callback but I am not sure how to make it work.
Any help will be appreciated.
Thanks
In SurfaceCreated, set the display surface of the player - setDisplay(holder)
I'd like to add some functionality inside of default media player for honeycomb without making any other class that using mediaPlayer package from Android, such as showing the information for particular video by swiping the screen, etc. Is that possible? if not, there's no other way to make my own class for the media player :(
No, that is not possible: the default media player on Android can not be modified by third party code. If you want to build your own media player you can start by looking at this and in the platform samples, but you will need to do significantly more work to get a fully functional media player.