Hide video but have it continue to play - android

I have an image and a video player. In portrait, it shows both. Doing landscape left, just the video shows. Doing landscape right just the image shows.
I am using the setVisibility() method right now to achieve that. The problem with doing:
myVideoView.setVisibility(View.INVISIBLE);
causes the video to stop playing. Is there a way to keep it playing but also not visible to the user? Maybe like set the opacity of the VideoView to 0?

I think I found a solution here. In order to make videoview invisible and keep it playing sound you simply hide it by setting alpha value.
mVideoView.setAlpha(0f);
Hope it works for you!

You could try changing the z-order of the views with the bringToFront() method.
If you want the video to show then call mVideoView.bringToFront() and when you want the image to show you could use mImageView.bringToFront() this should work as long as the video and the image both occupy the same space on the screen.
Good luck

Related

how to add full width ripple effect with some margin around it in android

I don't know how to explain my problem to you. so I start explaining.
now I have one item, on clicking that item I want to to do something . all works fines. but the problem is ripple effect start or finish with some margin. Because I want to add some margin from around.
I don't want to waste your time by just reading. so I show you some images.
here in above image i shows you ripple effect on account switch option of my youtube app. this is i want to do.
here in above image I want to make ripple effect full width even i add some margins around item like youtube does this.
so how can I achieve the same thing which youtube does?
sorry for less writing my problem but above images tells my problem and you can also understand my problem by seeing this images.

Full HD video in VideoView issues

I'm playing a Full HD video inside a VideoView, but my screen size is just 1216px x 684px.
The VideoView is cropping the video, but I want it scaled down. I found one "bug" that makes what I want, but surely it's not the best way. If I set 1px margin around the VideoView, it scales correctly.
The VideoView is inside a RelativeLayout, I tried to set centerInParent, "alignParentLeft, Right, Top and Bottom" but none of this works.
Is there another way to make VideoView correctly scale the source?
Another issue:
When I pause my VideoView, it goes dark, instead of freezing the image. Is there a way I could achieve this behavior?
Thanks in advance for every reply.

TextureView and Transparency

I have a TextureView with a mediaPlayer attached to it, so i can use its surface to display a video, so far it's working well.
Now i try to create a fade in animation for displaying the video and i have no clue of how to do it.
I tried with the setOpaque(false) setting and playing with the alpha setting but it doesn't have any effects.
Also i tried the textureView without a mediaPlayer and i notice that i can't change the background color either, it's always black.
The documentation say that the behaviour of this view is the same as the standard view, but it doesn't seem to be the case.
Does anyone know how to change the transparency of this view ?
Thanks
I also had this problem, and you just need to set setAlpha(0.999f) and it will have transparent background.

VideoView invisible in Popupwindow?

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,

Android VideoView plays 2 videos at the same time

I am trying to play a videoview on top of another video view. The first video view is paused, while the second is playing. It appears to work but no second video appears on the screen (though I hear the audio and see the controls that would normally appear on top). I am assuming this is some sort of order issue. Any thoughts. By the way, I have no problem displaying other views on top of the main video view and having the video fill the background.
That won't work - the VideoView is special in the sense that it 'punches' a hole in the normal Views to allow direct access to the display pixels (or, in android terms, the 'Surface' - VideoView is a subclass of SurfaceView). You cannot layer two SurfaceViews on top of eachother - the first one that grabs the pixels (the Surface) will 'own' it. (see SurfaceHolder.Callback.surfaceCreated() / surfaceDestroyed())
Other Views on top of a SurfaceView do work, because the framework will compose the display bits of normal Views on top of the Surface. It cannot do that with another VideoView (i.e. a SurfaceView) because there is nothing to compose.
<VideoView android:id="#+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<VideoView android:id="#+id/videoView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
when videoView2 starts playing setvisibilty of videoView1 invisible.
then you can make it visible when you need.
Use Thread to control both video
I don't know if this is helpful at the moment, but I managed to get something similar to what you want...
I needed to nest a VideoView on top of a SurfaceView; as long as they don't overlap 100% it can work. (what i mean is, my surfaceview is the whole screen and videoview is just a small portion of the screen)
The thing is - since you can't compose SurfaceViews, the first one to grab the pixels is the one that will be shown. Intuitiveness will drive you to Z-order your prioritized view AFTER the less-important one in the XML - but as I've said previously, the first one to grab the pixels stays, so make sure you define the smaller view FIRST, and then overlay it with the bigger one.
This will result in such behaviour that the smaller (in my case preview view) acquires the said X * Y pixels, and then the 'background' surfaceview (which is supposed to be on top of it according to the XML) takes up the rest and ignores the smaller surface.
I'm not too sure about handling events from those two though as I only have to play streams in those two views and not react to any kind of clicks/events generated by those two components, but it might be expected that if you followed this route - the bigger view will intercept all clicks made in the smaller view area (because it's on top according to the XML) so maybe you have to programatically move it on top as well upon creation.
Hope it helps.
EDIT:
Although... it like it just works once. It's a work in progress really. Upon returning from any activity, there's nothing i can do to prevent the bigger view claiming everything :/
you can add videoview a on top videoview b,like this,
parentview.removeview(a);
parentview.removviewe(b);
parentview.addview(a);
parentview.addview(b);
parentview.invalidate();
Ti's work for me. I hope it can helps.

Categories

Resources