Pause and restart Soundfile

How to pause and restart (from paused position) a Soundfile (mp3) ?

Try this code:

import ddf.minim.*;

Minim minim;
AudioPlayer player;

void setup() {
  minim = new Minim(this);// initialize minim object
  player = minim.loadFile("myFile.mp3");// load the file, must be located in the data folder

void draw() {
  // nothing to do here.

void keyPressed() {
  if (player.isPlaying()) {
    player.pause();// pause the soundfile
  } else {;// resume

You’ll need to install minim (if you don’t already have it).
To do that, go to Sketch > Import Library… > Add Library… and type “minim” in the “Filter” input box. Then select Minim | An audio library and click “install”.

1 Like

@DongKingKong0 Thanks :smile:
Is it possible with the Sound processing library ? :confused:

I don’t know an easy way, but there might be one… I’d recommend you to use minim in this case, but that decision is on you :wink:

@cameyo pausing and resuming is not possible with the current Processing Sound library, but if you’re feeling adventurous you could try out the new version of the library which does support resuming (unfortunately you can’t install it through the Processing library menu yet, so you’d have to download+install it manually): see Early builds of the new Processing Sound library available for testing

@DongKingKong0 I’ll try Minim :slight_smile:
@kevinstadler Thanks for your work. I’ll test the new library the next days