I have an app that I'm working where in one activity I'm using a VideoView while setting the theme for that activity translucent (transparent) : android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
However I'm noticing odd behavior from the videoView - for a split second before the video starts playing (it's auto play) the frame where the videoView is itself transparent and you can see the activity behind it. For reference the activity in question has other elements to it and the video is framed.
Is there anyway to make this black or even a custom image that covers the frame before the video starts?
videoView.setBackgroundColor is buggy and actually changes the foreground color and keeps the frame that color while playing...
thanks for your time!
videoView.setZOrderOnTop(true);
SurfaceView (and VideoView as subclass) is placed behind the window by default. So you should call: videoView.setZOrderOnTop(true) if you want to place it on top (to make it non transparent).
You can cover the ViewView with another View and then as soon as video playing starts you can animate this View out, let's say quickly changing its alpha to 0.0.
Please read this response in other SO thread, i think it's the solution for this problem, at least it worked for me
Related
Phone only with Android 4.0+ and no other third party libraries.
Application uses Navigation Tab of the ActionBar. One of the tab contains the stock VideoView control from ICS streaming live video from a source. I want to have the VideoView keep playing when user switch tabs to view information (call it InformationView).
On a tablet, I don't have this issue because the screen size is bigger and I make VideoView always on screen.
On a phone, screen is smaller therefore tab must be used.
I understand that VideoView probably depends on a visible surface in order to draw the video frame. When user switch tabs, the surface isn't available to VideoView therefore it automatically stops.
I can probably work around this by using a big scrollview that contains both InformationView and VideoView.
Is there any way to force it keep playing (maybe by drawing to an invisible surface) or is there a third party library that mimic the 'tab' behavior by using a giant scrollview so I don't have to write more code?
Note this isn't the same as multiple VideoViews problem which described here: One videoview blocked by another videoview
OK the solution is to hide the fragment that contains the VideoView when switching tabs, hence there is always a 'surface' video view can draw to.
You can custom VideoView same default but that's different you should control holder surface, oncreatSurface, onchangeSurface().
A better implementation of this concept would be not to use the stock VideoView widget, which is really just a marrying together of a SurfaceView and a MediaPlayer, but to divorce these two and use them individually. If your application controls the MediaPlayer directly, is can continue to play the audio track even after the surface disappears.
Making your Activity or Fragment one of the SurfaceHolder.Callback instances attached to the SurfaceView will allow you to know when the surface is or is not available for drawing. The MediaPlayer methods setDisplay() and setSurface() would be then used in your application to attach and detach the video surface when it becomes available in the view hierarchy per that callback.
You may also find the source of VideoView helpful (link) in coming up with your own implementation that accomplishes a similar goal.
I have a viewpager which has two views in it. On the first view I have a list of videos and on the other one I play the video.
The issue is when I play the video on the second view and if I want to go back to the first view, there is a black rectangle remaining from the video. it disappears after a few seconds.
I am using a galaxy note running ICS.
Can it be because of memory usage?
Thanks,
I solved this problem long time ago by setting background color of the videoview to some color and then making it '0' onVideoPrepared().
Well, do you "stop()" the video when you start dragging the page ?
if not, then you need to add a OnPageChangeListener to the viewpager, so when you start scrolling/dragging the page, you stop the videoview, that should fix your problem,
the more probable thing is that for optimization reasons does not want to be playing the video as dragging the page so puts a "picture" of the video while moving.
My application has several pages of book. In some of page I am playing video using video view. I am checking if I have any video for that page. If yes, than I am making videoview visible and passing Uri. If not, I am making it gone.
Now the problem is, once i reached to that screen and then if I swipe left/right it's creating black window in every subsequent screen. Why?
I found solution. When you want to show video make videoView.setZOrderOnTop(false); and when you want to hide video view jusr make videoView.setZOrderOnTop(true);
Can we move a playing video from an activity to a popup dialog without disturbing the play?
I have tried it, but failed to manage to get it work with the SurfaceView as its creating a hole in the popup and is displaying the content in the Activity behind.
Alternately, tried removing the video (either being played in SurfaceView / VideoView) from activity and added to a dialog. But, this re-buffers the video and I want to play continuously without a re-buffer.
Any suggestions would be appreciated
you can see this link for that if any prob then ask me be friendly
I have not tried it myself to say for certain, but I think if you put a VideoView as the argument into http://developer.android.com/reference/android/app/Dialog.html#addContentView(android.view.View, android.view.ViewGroup.LayoutParams) it should be what you're after. Just make the alert be brought up on the button's listener. It's http://developer.android.com/reference/android/widget/VideoView.html that you want to send in an instance of.
Set below theme to android mainfiest of class file which have videoview or surface view.
<activity android:theme="#android:style/Theme.Dialog">
try this it may help you.
I have a webview that's playing a video, and I want it to appear behind some other views, but I can't seem to make it happen. I've tried simply just sending the foreground views to the front with bringChildToFront(View v), but no cigar. Any thoughts?
Edit: Some more details: The webview plays a video using flash, and the webview is the size of the entire screen. I have some stuff I want to pop up in front of the video, but they only stay behind the video. They're definitely there, as they receive touch events and stuff, but just hidden away from view by the video.
Since the Flash player will essentially pre-empt any other views in the window, you'll just have to do one better over Flash: use another window on top of the main window.
Android allows you to do this by using the PopupWindow class.