Question

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.

Was it helpful?

Solution

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);
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top