android - ImageVIew Thumbnail setVisibility GONE not working inside onPrepared -
i want hide imageview
thumbnail after remote video ready play, means when onprepared
execute imageview.setvisibility(view.gone)
doesn't works @ all.
i have seen answers one, two , think cause surfaceview
or videoview
. per answers
i have tried using both mediaplayer
, videoview
code using mediaplayer , surfaceview
mmediaplayer = new mediaplayer(); holder.surfaceview.setdrawingcacheenabled(true); try { mmediaplayer.setaudiostreamtype(audiomanager.stream_music); mmediaplayer.setdatasource(mcontext, uri.parse(video_url)); mmediaplayer.setonpreparedlistener(new mediaplayer.onpreparedlistener() { @override public void onprepared(mediaplayer mp) { mp.start(); ((activity)mcontext).runonuithread(new runnable() { @override public void run() { holder.imgthumbnail.getparent().requesttransparentregion(holder.imgthumbnail); holder.imgthumbnail.setvisibility(view.gone); holder.imgthumbnail.getparent().requesttransparentregion(holder.imgthumbnail); } }); toast.maketext(mcontext,"onprepared",toast.length_long).show(); } }); } catch (illegalargumentexception | securityexception | illegalstateexception | ioexception e) { e.printstacktrace(); } mmediaplayer.prepareasync();
xml of surfaceview
<relativelayout android:layout_width="410dp" android:id="@+id/v_view" android:visibility="visible" android:layout_height="307.50dp"> <surfaceview android:id="@+id/video_view" android:layout_width="410dp" android:layout_height="307.50dp" /> <imageview android:id="@+id/imgthumbnail" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="visible" android:scaletype="centercrop" /> </relativelayout>
code using videoview
videoview.setonpreparedlistener(new mediaplayer.onpreparedlistener() { @override public void onprepared(mediaplayer mediaplayer) { log.i(tag,"onprepared"); new handler().postdelayed(new runnable() { @override public void run() { videoview.start(); toast.maketext(mcontext,"start video",toast.length_long).show(); ((activity)mcontext).runonuithread(new runnable() { @override public void run() { holder.imgthumbnail.getparent(). requesttransparentregion(holder.imgthumbnail); holder.imgthumbnail.setvisibility(view.gone); holder.imgthumbnail.getparent(). requesttransparentregion(holder.imgthumbnail); } }); } },100); } });
xml of videoview
<relativelayout android:layout_width="410dp" android:id="@+id/v_view" android:visibility="visible" android:layout_height="307.50dp"> <videoview android:id="@+id/video_view" android:layout_width="410dp" android:layout_height="307.50dp" /> <imageview android:id="@+id/imgthumbnail" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" android:background="@color/back_orange" android:scaletype="centercrop" /> </relativelayout>
please help! i'm stuck
Comments
Post a Comment