InteractivePlayerView
InteractivePlayerView copied to clipboard
music progress time shows random numbers
First of all i liked your player view very much, but when i tried to implement it, im getting some problems.
In my player when i tried to to the music progress time , when the music starts ,player shows some random numbers as time.
Can you pls help me to fix this :
* this is my screenshot*
my code used is :
ipv = (InteractivePlayerView) v.findViewById(R.id.ipv);
mPlayer = MediaPlayer.create(getContext(), R.raw.music);//Create MediaPlayer object with MP3 file under res/raw folder
ipv.setMax(mPlayer.getDuration());
ipv.setOnActionClickedListener(this);
final ImageView control = (ImageView) v.findViewById(R.id.control);
control.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mPlayer != null && !ipv.isPlaying()) {
ipv.start();
mPlayer.start();//Start playing the music
final Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
// while (mPlayer != null && currentPosition < total) {
try{
ipv.setProgress(mPlayer.getCurrentPosition());
//do your code here
}
catch (Exception e) {
// TODO: handle exception
}
finally{
//also call the same runnable to call it at regular interval
handler.postDelayed(this, 1000);
// }
}}
};
handler.postDelayed(runnable, 1000);
control.setBackgroundResource(R.drawable.pause);
} else {
ipv.stop();
if (mPlayer != null && mPlayer.isPlaying()) {//If music is playing already
mPlayer.pause();//Stop playing the music
control.setBackgroundResource(R.drawable.play);
}
}
}
});
Hai now i figured out the my problem by changing the ipv.SetProgress
code to ipv.setProgress(mPlayer.getCurrentPosition()/1000);
but now the weird number showing problem solved but now the red seekbar is not updating its view.
Still no answers..?
You sure you didn't forget ipv.start();
right after that ?
Any work around this issue ?