I'm facing weird issue of flickering using VideoView
. When activity starts, it causes minor flicker of fraction for a second. Then, video starts. It shows 2 black lines on the top and the bottom of the video. See the snap-shot below.
I have tested my application on 2 devices
1) Samsung n-8000(Tablet)
2) Lenovo a-800
video.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:gravity="center">
<VideoView
android:id="@+id/vvSplash"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#00ffffff">
</VideoView>
</LinearLayout>
Activity code:
private VideoView vd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.video);
vd = (VideoView) findViewById(R.id.vvSplash);
playVideo();
}
private void playVideo() {
Uri uri = Uri.parse("android.resource://" + getPackageName() +"/"+ R.raw.intro);
vd.setVideoURI(uri);
vd.setMediaController(null);
vd.start();
}
Any help would be appreciated. Thank you.
Flickering in video and film is a common problem resulting from certain frame rate and shutter speed combinations under artificial lighting. This article gives an overview of why this happens, along with recommending settings for minimizing the chances of this happening in the first place.
The frequency of each video frame is far higher than the frequency of such lights. As a result, some frames of the videos are shot when the light is on while others are shot when the light is off. This is what causes flickering or ripples to appear in videos.
As ridiculous as it sounds, but the answer is here:
I repeat the solution, kudos to those who found out:
<SurfaceView
android:layout_width="0px"
android:layout_height="0px"
android:visibility="gone" />
It is VERY IMPORTANT that you add the surface view to the root view in your activity, not the immediate parent. Otherwise it won't work.
i also faced same problem but solved it by changing layout parameter of videoview from wrap content to match parent . Also you need to remove the background property of video view from XML. I hope it will work for you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With