android progress bar movement with audio - android

How can I make progress bar or progress dialog movement with audio in android
I am trying to design an audio player. I need help regarding the progress bar. I want the status of progress bar to change as the audio progresses. I want progress bar to pause as I press Pause button and start again as I press start button. Please help...
Thanks

Step 1:
Get audio duration with MediaPlayer.getDuration()
Step 2:
Set ProgressBar progress max. value to value from step 1
Step 3:
Update progress bar periodically from MediaPlayer.getCurrentPosition(), while media playing using Handler. Check here
Remember to;
Stop periodic update of step 3 at pauses and stops
If you are going to add seek progress bar feature use MediaPlayer.seekTo(int msec) method, where msec is SeekBar.getProgress(), using SeekBar.OnSeekBarChangedListener
Good Luck!

Related

ActionBar-PulltoRefresh, wrong header offset when setting the activity to fullscreen

I am using ActionBar-PulltoRefresh by Chris Banes, it is a great libary to have.
However, I run into a weird problem when I set my activity to fullscreen. I set auto-refresh in the onResume() function, where I also show the progress bar animation.
However, sometimes(esp. when come back from the screen lock) the status bar take some time to hide(there is a short animation), and the header and the progress bar were overlaid in wrong location, i.e. below the real location of the action bar. The offset seems to be exact the size of the status bar.
However, if I trigger the refresh a few seconds later after the activity is fully shown, there is no problem. But I don't want to add a fix delay to the auto-refresh operation in onResume().
Any better fix for this problem?

how to hide the seek bar when the Media player is not playing?

I am developing a Media Player and i want to display seek bar only when the song is being played and when the song is not played or is paused i want to hide the seek bar,please help in achieving this.
i am developing android app on a htc wild fire which has android froyo 2.2 running in it.
setVisibility(View.GONE);
Call on the seek bar should do the trick. Subsequently, to make it reappear during other operations call:
setVisibility(View.VISIBLE);
Hope this helps.
Use somthing like that :
if(mediaPlayer.isPlaying() == false)
{
seekBar.setVisibility(View.GONE);
}

Audio progress bar for Android

I have an audio program that I would like to add an audio progress bar with some kind of button, so that a user can grab the button to navigate through the audio forward or backward.
Is there any kind of standard component that does that? Or how can I make a custom one?
You can use SeekBar.
To position and seek the audio, use MediaPlayer's getCurrentPosition(), getDuration() and seekTo(int).

Pop-up message after progress bar completes?

hey..hi..please tell me if i want to show pop-up message after completing my progress bar which is on 1st activity. now i have created progress bar its runs but remaining part i want to show pop-message as progress bar reached the max. limit....please help me out
Have you tried using a Toast?
(You may also want to change the title of this submission to something more relevant.)
have a look at http://developer.android.com/reference/android/widget/ProgressBar.html#getProgress%28%29
and http://developer.android.com/reference/android/widget/ProgressBar.html#getMax%28%29
You can write something like
if (yourBar.getProgress() == yourBar.getMax()) do something

Android progress bar

HI All,
I m calling one webservice(SOAP) on Click of button. Web service is taking around 20 secs to get response. in the mean time i want to show progress bar.
So how can i do that?
where should i code for progress bar? on button click? any source code, example would be very helpfull.
Thanks in advance.

Categories

Resources