I have an mp3 file and I want to play a specific word in it. I have a start time (6889 ms) and end time (7254 ms).
I have these codes:
In Oncreate Method ,use the below 4 lines code:
MediaPlayer mPlayer = MediaPlayer.create(this, R.raw.nicholas);
mPlayer.start();
mPlayer.seekTo(startTime);
updatePlayerPostion();
private Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
updatePlayerPostion();
}
};
updatePlayerPostion()
{
handler.removeCallbacks(r);
if(player.getCurrentPosition==7254)
player.stop();
else
handler.postDelayed(r, 1); //1 millisecond
}
Runnable r=new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
updatePlayerPostion()
}
};