android - VideoView inside fragment causes black screen flicking -


we have android application running on android api 4.0. 1 of activities has layout divides screen in 2 parts. on left side have static part buttons. on right side have framelayout switch corresponding fragment depending on button pressed.

problem: 1 of fragments on right side contains videoview. when user clicks on button show fragment fragment shown , video starts playing however: upon rendering fragment complete screen flickers in black annoying.

here code of videofragment class:

public class videofragment extends fragment {      public videoview videoview;      private externalvideo mvideo;     private boolean mvideoexists;     private string mdestination;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         mdestination = applicationparams.media_storage_path + "videos/"                 + filenameutils.getbasename(((detailactivity)getactivity()).getproduct().getvideourl())                 + "."                 + filenameutils.getextension(((detailactivity) getactivity()).getproduct().getvideourl());          file file = new file(mdestination);         mvideoexists = file.exists() && file.isfile();     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view view;          if (mvideoexists) {             getactivity().getwindow().setformat(pixelformat.translucent);             view = inflater.inflate(r.layout.video, null);             mvideo = new externalvideo(mdestination);              videoview = (videoview) view.findviewbyid(r.id.video_video);              mediacontroller mediacontroller = new mediacontroller(getactivity());             mediacontroller.setanchorview(videoview);              videoview.setmediacontroller(mediacontroller);             videoview.setvideopath(mvideo.getfullpath());             videoview.requestfocus();             videoview.setvisibility(view.visible);              videoview.setonpreparedlistener(new mediaplayer.onpreparedlistener() {                 public void onprepared(mediaplayer mp) {                     videoview.start();                  }             });         } else {             textview textview = new textview(getactivity());             textview.settext(getactivity().getstring(r.string.videofragment_video_coming_soon));             textview.setpadding(50, 50, 50, 50);             view = textview;         }          return view;     }  } 

here layout of video fragment:

<?xml version="1.0" encoding="utf-8"?>  <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"               android:layout_width="match_parent"               android:layout_height="match_parent">     <videoview android:id="@+id/video_video"                android:layout_width="fill_parent"                android:layout_alignparentright="true"                android:layout_alignparentleft="true"                android:layout_alignparenttop="true"                android:layout_alignparentbottom="true"                android:layout_height="fill_parent"/> </relativelayout> 

does have idea causing flickering issue upon rendering fragment contains videoview? solution appreciated!

edit1: if click on fragment videoview on screen flickers in beginning. when navigate anoter fragment , go 1 containing videoview flicker gone.

i able fix adding 0px 0px surfaceview in layout of parent activity of fragment:

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

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -