I got a videoView, that plays in landscape. When rotating the device I want to switch to full screen. Just like youtube does.
In my solution when going to landscape I start new activity in full screen mode and trying to continue playing from where I stopped.
The problem is that it takes to long and there is a black screen for a moment. Do you have any suggestion how to improve this?
Related
I use EasyVideoPlayer library in my Android application, when the video appears doesn't see the video, I only view a black screen. But when I rotate the screen to portrait or landscape it works perfectly. I donĀ“t know what is the problem...
My code:
EasyVideoPlayer vVideo = (EasyVideoPlayer) findViewById(R.id.vVideo);
vVideo.setCallback(this);
vVideo.setSource(Uri.parse(url));
vVideo.setAutoPlay(true);
vVideo.start();
Thanks in advance
When you rotate the device, unless you have orientation locked which does not sound like it is there case, Android will kill your activity and restart it.
The reason it does this is to allow the activity be recreated with the correct resources for the new orientation - in fact it does the same thing for other configuration changes also, such as a language change.
So, take a look at the code that gets called when your activity is destroyed and recreated, in particular 'onCreate', 'onResume' etc - you will most likely find that something is being done here which allows the video to play correctly but which is missing when you hit the 'play' button normally.
My target: I am trying to play a video when tapping on one of the item on the screen while still staying on that screen.
So I resort to PopupWindow but somehow VideoView doesn't show up in the popup.
I can display popup just fine but the VideoView doesn't(in fact, it's not invisible but rather freeze that section of the screen). If you look at the second and third screen, you will see that the invisible area isn't exactly rectangular. That's because I am animating the popupwindow.
I checked the VideoView itself inside another Activity and it plays nicely. I tested this with Nexus One and Galaxy S, both display the same result.
Quick search on StackOverflow shows this question : android video, hear sound but no video
which leads to
Android not playing Video .mp4
and both doesn't work for me.
Also, as you can see on the third screen, the MediaController doesn't exactly attach itself to the video or popupwindow but the Activity instead.
Here's the screens,
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Avoid Android VideoView corruption when rotating back to portrait
I've managed to write a limited video player able to view a .3gp file from internet. The video will be shown centered full screen, maintaining the video aspect ratio. Also, rotations don't interrupt the video, which keeps playing without problems.
Everything seems fine, but... on my HTC Legend when you rotate back to portrait, the video is corrupted, and instead of showing full screen it is displayed at its native pixel size. But rotating again to landscape works and is shown perfectly. Any ideas why? Unfortunately I don't have more hardware to test this on and I've run out of ideas to test.
You can get the full example source code from https://github.com/gradha/Android-video-stream-rotation. Here are screen captures of me opening the application, rotating to landscape, touching the screen to display the video controls, then rotating back to portrait to see the corruption.
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this source save me
I have a video that plays in portrait mode. At the end of the video, I need to display some views over it. This works fine so far.
I am however, having a problem where views that are over the last frame of a video don't redraw properly when coming back to the activity after turning the screen off, then on again, then unlocking the screen.
What i'm observing is that when the screen comes back on and I unlock. My video and images are first rendered outside of fullscreen mode (with the status bar still showing) then the screen will go into fullscreen mode shifting all of the views up and causing artifacting.
It seems like the views are being shifted out of their view bounds by the transition to fullscreen after they are rendered.
I'm really stumped as to how to prevent this from happening.
Here is the sandbox project on github to avoid making this a post full of code.
The basic setup for the project is this:
Fragment activity has a video view and a button view on it's layout.
It then adds a fragment into a contentView container. The contentView fades in 1 second prior to the end of video playback.
Everything works smoothly and the problem is with returning back to the app after powering the screen on and off.
Also, sometimes the video will just drop out entirely, leaving the views sitting atop a black background.
Thanks in advance for any help you can provide.
Here's the artifacting that happens when you turn the screen off, back on, and unlock.
Note that I had to take a picture of it. On DDMS the screenshot tool sees the images properly.
rather than prevent the screen from turning off, you can opt in to receive an event when the user unlocks the keyguard after waking the phone.
At this point, it might be a good idea to call View.invalidate on both of your views, this should cause a redraw. The draw chain is very flaky while the lock screen is up, because your app is technically visible, just under the lock screen.
registerReceiver(new BroadcastReceiver() {
#Override
public void onReceive(Context ctx, Intent intent) {
if(intent.getAction().equals(Intent.ACTION_USER_PRESENT))
}
}, new IntentFilter(Intent.ACTION_USER_PRESENT));
It looks like the overlay layout was shifted by controller bar.
Don't you think it was affected by controller (play/pause/ff/rew + progress) area?
there may be a way to prevent the screen going off in 1st place as this would be good resolving your re draw issues, hope this helps.
My target: I am trying to play a video when tapping on one of the item on the screen while still staying on that screen.
So I resort to PopupWindow but somehow VideoView doesn't show up in the popup.
I can display popup just fine but the VideoView doesn't(in fact, it's not invisible but rather freeze that section of the screen). If you look at the second and third screen, you will see that the invisible area isn't exactly rectangular. That's because I am animating the popupwindow.
I checked the VideoView itself inside another Activity and it plays nicely. I tested this with Nexus One and Galaxy S, both display the same result.
Quick search on StackOverflow shows this question : android video, hear sound but no video
which leads to
Android not playing Video .mp4
and both doesn't work for me.
Also, as you can see on the third screen, the MediaController doesn't exactly attach itself to the video or popupwindow but the Activity instead.
Here's the screens,