문제

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.

도움이 되었습니까?

해결책

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);
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top