how to show the progress bar before playing the video

后端 未结 3 1193
死守一世寂寞
死守一世寂寞 2021-02-06 07:36

i want to show the progress dialog before playing video. i tried below link example for playing video.

http://davanum.wordpress.com/2009/12/04/android-%E2%80%93-videomus

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 07:52

    I would suggest looking at the AsyncTask documentation, this seems ideally suited for doing video pre-loading. This will allow you to keep your UI thread stable during loading. There is an example of using the AsyncTask method here.

    To add a progress dialog:

    • Create a private ProgressDialog object as part of an extension class of AsyncTask.
    • In the onPreExecute() method you can perform progress dialog setting up, such as: pd.setMessage(...) pd.setTitle(...) pd.show(...)
    • In the onPostExecute(...) method, dismiss the dialog: pd.dismiss();

    Additionally, you can update the progress dialog using its incrementProgressBy(...) method, or alternately have a looping animation using the setIndeterminate(...) method. Giving the user feedback of the loaded progress is a good idea in UI design :)

    I hope this helps!

提交回复
热议问题