You will need to use the AdvancedPlayer class instead of the simple Player , because the simpler one cannot start playing the file in the middle.
You need to add a PlaybackListener and listen to the stop() method. Then you can just start from the moment you stopped.
private int pausedOnFrame = 0; AdvancedPlayer player = new AdvancedPlayer(fis); player.setPlayBackListener(new PlaybackListener() { @Override public void playbackFinished(PlaybackEvent event) { pausedOnFrame = event.getFrame(); } }); player.play();
This will remember that the frame is paused (if it is paused).
And now, when Play is pressed again after a pause, you check if pausedOnFrame will be a number from 0 to the number of frames in the file and call play(int begin, int end) .
Please note that before that you must know the number of frames in the file. If you do not, you can try to play back all the frames with this trick:
player.play(pausedOnFrame, Integer.MAX_VALUE);
However, the API does not seem to be very useful in your case, but it is the best thing you can do except move to another library.
source share