简体   繁体   中英

How to show progress bar until video play in live stream Android?

i am working on an application where i need to play video from a remote server as live stream.

which is done by me successfully. i managed every thing in my app.

but when video is loading i need to show a progress dialog over VideoView.

i tried using OnPreparedListener as " how to show the progress bar before playing the video "

@Override
public void onPrepared(MediaPlayer mp) {
    progressbar.setVisibility(View.GONE);
    mp.start();

}

but video play after 5-7 Sec of progressbar gone. i searched a lot on Google but not found any solution for it.

Could anyone help me.

Thanks in Advance.

have a look this one solved my problem hope help you also..

http://www.quicktips.in/how-to-show-progressbar-while-loading-a-video-in-android-videoview/

 progressbar.setVisibility(View.VISIBLE);

 videoView.setOnPreparedListener(new OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mp) {



                mp.start();

                mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() {

                    @Override
                    public void onVideoSizeChanged(MediaPlayer mp, int arg1, int arg2) {
                        // TODO Auto-generated method stub
                        Log.e(TAG, "Changed");
                        progressbar.setVisibility(View.GONE);
                        mp.start();
                    }
                });


            }
        });

:)

Unforgettably there is no OnStart Listener expose by Android. After Prepared State, the MediaPlayer goes into Started State once playback started.

But in Prepared State only you should have sufficient buffer to play. Can you use setOnBufferingUpdateListener (MediaPlayer.OnBufferingUpdateListener listener) and print percentage of buffer. So that way you can see, if in Prepared State you have enough buffer or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM