I am working on a video streaming application like YouTube. I am using VideoView's built in streaming capability.
I am using Fragments, so on phones there is a Activity wrapper around VideoFragment.
The UX should be similar to YouTube's, so in portrait there is video playing at the top and some aditional views below it, etc., and in landscape, all there is is a fullscreen video.
What I have trouble with is orientation changes, what I obviously want is have video continue playing when orientation is changed. As I said, the video is streamed, so just persisting the current video time is not going to cut it. The only way I managed to do that is by forcing to not restart activity with android:configChanges="keyboardHidden|orientation|screenSize" set on the wrapper activity in Manifest.
So this works nicely, but fails when I want to have different layouts for layout and layout-land as YouTube does, because the activity is not restarted, so theres no oportunity for fragment to load new layout as far as I know.
Thanks!
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 have a website with lots of video. Currently I am struggling to develop an app version of my website. I am developing the app in android studio and using webview to show the website in the app.
Currently I have two issues related to video playing.
First one is, if I am holding mobile phone in portrait mode, and I play a video. Video plays smooth. But if I tilt the phone to landscape mode, the audio still plays but a new website loads where video is not playing.
Second issue is, I want to achieve when a user tilts the phone from portrait to landscape mode, if a video is playing then it should occupy entire screen of phone. Similar to youtube. If a video is playing in portrait mode and if you tilt the phone then the video occupies entire screen, I want such result.
Sorry for my bad english. Please guide me. Thanks in advance.
Fast googling, it gives you anything you need to know.
http://tekeye.uk/android/examples/ui/android-portrait-landscape-screens
So you must just define two layouts, one for landscape, and one for portrait orientation.
Then just handle how it should look in both of them.
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.
In my app, I use several independent VideoViews in order to buffer videos one after another while only one video is playing at the same time.
I observed that when one video is playing and I call VideoView.setVideoURI on a VideoView in the background in order to start buffering, the currently visible video will suddenly be cropped to the dimensions of the video that is loading in the background.
I assume that this is a low-level bug within the Android system which will crop the existing video rendering layer as soon as there's new video data available, even if both videos and VideoViews are actually independent.
Has anybody also noticed this behaviour and knows a workaround?
Thanks!
I am basically running a set of video tracks using a custom media player. Every thing works fine until I press home button or go to any other screen, then on after returning to the video play screen I can only hear the audio track as the videos play and screen appears black.
I would also like to highlight another issue for which i have got a stop gap arrangement, which is when i switch videos in the playlist, the surface view retains the last frame or image of the video that was previously played. I have tried to invalidate(), force the layout and all possible ways to refresh screen that i could think of, yet I couldn't find an appropriate solution for both of the issues mentioned.