0

I want that after incoming call Track continues from point stop

I use this code:

public void playerUpdate(Player player, String event, Object data) {

    if(event == PlayerListener.DEVICE_UNAVAILABLE) {
        player.stop();
        isPause = true;     
    }
    if(event == PlayerListener.DEVICE_AVAILABLE) {


        if(isPause == true) {

            player.start();


        }
    }

}

But it isn't work. Track restarts.

gnat
  • 6,213
  • 108
  • 53
  • 73
Tim
  • 1,606
  • 2
  • 20
  • 32

1 Answers1

3

instead of updating code in PlayerUpdate , please use a boolean value and when call gets interrupted automatically midlet goes to hideNotify() and save the mediaTime (is available) and resume player with showNotify() method and changing boolean value and starting player with player.start(); and player.setMediaTime(savedmTime);

here is piece of code.

protected void hideNotify() {        

    resume = false;
    paintMessage = false;


    mediaTime = player.getMediaTime();
}

// calls while resuming the application.

protected void showNotify() {
    if (mediaTime != 0) {
        if (pause) {

            resume = false;


            midlet.lcduiDisplay.callSerially(repainter);
            mediaTime = player.getMediaTime();
            pausePlayer();
        } else {


            resume = true;


            long med = mediaTime / 1000;
            med = med / 1000;
            message = "Resuming...from " + med;

            play(mediaTime);
        }
    }
}
Vijay YD
  • 514
  • 1
  • 4
  • 15
  • After Incoming Call player.getMediaTime() always returns 0. What is the problem? – Tim Apr 25 '12 at 13:00
  • you need to store mediaTime globally and save before calling hideNotify() and check player.getDuration is that returning positive value or not . – Vijay YD Apr 25 '12 at 13:16