Search code examples
androidandroid-videoviewandroid-video-playerandroid-tv

videoview screen fade black in android TV


I try to play video from raw folder.I wrote some codes and everything is perfect in device.

    String UrlPath = "android.resource://" + getPackageName() + "/" + R.raw.background_video;
    videoView.setVideoURI(Uri.parse(UrlPath));
    videoView.requestFocus();
    videoView.start();

but i have problem android TV.first time i created both projects(device and TV). when i run my project in android tv,screen getting fade black,It looks like it adds some transparent black view in my VideoView. how i can solve this problem? thanks everyone


Solution

  • You can try the solution in this SO question by adding a SurfaceView. It looks like this:

    <SurfaceView
    android:layout_width="0px"
    android:layout_height="0px" />
    

    Another SO question that can help you with this problem is this: VideoView black flash before and after playing