Reputation: 233
Is there anyway I can add a ProgressDialog in VideoView in Android while the video is not showing up yet. Because all I see is black screen until the video plays. I have struggling for almost a week trying to find the solution, please help me I would really appreciate it a lot. Thanks in advance!
Here is the code I am using:
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse("http://www.yourvideos.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
Upvotes: 1
Views: 1177
Reputation: 21
best way is to use async task... preExecute method use showing dialog... doInBackground for setting the videoUri then in onPostExecute cancel the dialog... but if u had need to stop the Loading dialog as video starts playing, implement onPreparedListener and Register for the video view if you dont to want use async task then show the dialog before u set the path to videoview. then cancel it on "OnPrepared" listeners "onPrepared()" method. remember u should register with videoview...
Upvotes: 2
Reputation: 5212
I didn't test this but you might add the dialog, and populate it with the percentage fetched by http://developer.android.com/reference/android/widget/MediaController.MediaPlayerControl.html#getBufferPercentage()
use something like a timer to update it every few ms
Upvotes: 1