# Pause and restart Soundfile

**URL:** https://discourse.processing.org/t/pause-and-restart-soundfile/2122
**Category:** Libraries
**Created:** [July 27, 2018, 6:40am UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122 "2018-07-27T06:40:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cameyo](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cameyo](https://discourse.processing.org/u/cameyo)
#### Post date: [July 27, 2018, 6:40am UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122/1 "2018-07-27T06:40:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DongKingKong0](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dongkingkong0/32/960_2.png) [@DongKingKong0](https://discourse.processing.org/u/DongKingKong0)
#### Post date: [July 27, 2018, 10:34am UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122/2 "2018-07-27T10:34:06Z")

</div>

Try this code:

```auto
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 {
    player.play();// 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”.

---

<div class="post-metadata">

### Author: ![cameyo](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cameyo](https://discourse.processing.org/u/cameyo)
#### Post date: [July 27, 2018, 8:40pm UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122/3 "2018-07-27T20:40:00Z")

</div>

@DongKingKong0 Thanks 😄  
Is it possible with the Sound processing library ? 😕

---

<div class="post-metadata">

### Author: ![DongKingKong0](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dongkingkong0/32/960_2.png) [@DongKingKong0](https://discourse.processing.org/u/DongKingKong0)
#### Post date: [July 27, 2018, 8:57pm UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122/4 "2018-07-27T20:57:38Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![kevinstadler](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@kevinstadler](https://discourse.processing.org/u/kevinstadler)
#### Post date: [July 29, 2018, 5:25pm UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122/5 "2018-07-29T17:25:09Z")

</div>

@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](https://discourse.processing.org/t/early-builds-of-the-new-processing-sound-library-available-for-testing/1796/2)

---

<div class="post-metadata">

### Author: ![cameyo](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cameyo](https://discourse.processing.org/u/cameyo)
#### Post date: [July 31, 2018, 12:41pm UTC](https://discourse.processing.org/t/pause-and-restart-soundfile/2122/6 "2018-07-31T12:41:53Z")

</div>

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