Vignesh
Vignesh

Reputation: 2325

How to make button visible in video view "OnPreparedListener" method

I have play button and videoview in my activity. In xml, I made the button as invisible. In java code I'm try to make it visible.

In video view's OnPreparedListener method I'm trying to make it visible. but its not getting visible. below is my code.

        vvVideos.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                btnPlay.setVisibility(Button.VISIBLE);
            }
        });

XML File ::

<RelativeLayout
    android:id="@+id/bottomll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">

    <VideoView
    android:id="@+id/videoView"
    android:layout_width="fill_parent"
    android:layout_height="150dp"/>

    <Button
        android:id="@+id/btnPlay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/play"
        android:visibility="gone"/>

</RelativeLayout>

Upvotes: 1

Views: 810

Answers (1)

AndroidLearner
AndroidLearner

Reputation: 4636

Instead of this ::

 vvVideos.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                btnPlay.setVisibility(Button.VISIBLE);
            }
        });

Use this and Try ::

 vvVideos.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                btnPlay.setVisibility(View.VISIBLE);
            }
        });

Hope this helps :)

Upvotes: 1

Related Questions