# How can I start filePlayer from a given second? - New and going bananas

**URL:** <https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403>\
**Category:** Libraries\
**Created:** [April 4, 2020, 7:21pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403 "2020-04-04T19:21:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![goingbananas](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@goingbananas](https://discourse.processing.org/u/goingbananas)\
**Post date:** [April 4, 2020, 7:21pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/1 "2020-04-04T19:21:42Z")

</div>

Hi, so I’m very very new to processing and minim and I’m trying to get a filePlayer to start playing from a given second/millisecond. This is the code part where I’m calling the file to play:

```auto
void mousePressed(){
if(mouseX > 0 && mouseY > 0 && mouseX < 375 && mouseY < 500){ 
a=0; b=0; c=375; d=500; 
filePlayer.play(); 
filePlayer.rewind();} 

redraw();
}

```

I’ve been searching from forum to forum all the way down to Mordor’s gate and I can’t seem to find a way. Is this even possible? I thought this would be a basic Minim feature, but maybe it isn’t?

I’d really appreciate some advice! Thank you! 🙏

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 4, 2020, 7:26pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/2 "2020-04-04T19:26:54Z")

</div>

You mean click, wait 3 seconds and then start playing?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 4, 2020, 9:46pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/3 "2020-04-04T21:46:28Z")

</div>

Hello,

I have not yet tried this:  
[http://code.compartmental.net/minim/fileplayer\_method\_setlooppoints.html](http://code.compartmental.net/minim/fileplayer_method_setlooppoints.html)

I will leave it with you to try and let us know.

Also look in the examples:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8e19e873f7df7d5935b9aa171cdc7ca3ad12dde4.png)

And I tested it… but will leave that journey for you.

`:)`

---

<div class="post-metadata">

**Author:** ![goingbananas](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@goingbananas](https://discourse.processing.org/u/goingbananas)\
**Post date:** [April 4, 2020, 10:55pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/4 "2020-04-04T22:55:02Z")

</div>

Hi, no I mean click and starts playing but not from the beginning of the file, but from X second/millisecond that I suppose I have to specify and declare somehow

At this point I’m not even sure I explained myself before sorry

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 4, 2020, 11:00pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/5 "2020-04-04T23:00:36Z")

</div>

[http://code.compartmental.net/minim/fileplayer\_method\_cue.html](http://code.compartmental.net/minim/fileplayer_method_cue.html)

you can also use [http://code.compartmental.net/minim/fileplayer\_method\_play.html](http://code.compartmental.net/minim/fileplayer_method_play.html)

and `void play(int millis)`

see also [http://code.compartmental.net/minim/fileplayer\_method\_position.html](http://code.compartmental.net/minim/fileplayer_method_position.html)

---

<div class="post-metadata">

**Author:** ![goingbananas](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@goingbananas](https://discourse.processing.org/u/goingbananas)\
**Post date:** [April 4, 2020, 11:03pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/6 "2020-04-04T23:03:42Z")

</div>

Hi thank you, definitely going to try this one out. I’m a bit worried about the loop concept, because I only want it to play only once when clicked. You think this could work?

Sorry if I’m asking obvious questions… Didn’t lie when I said I was a newbie 🤕

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 4, 2020, 11:06pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/7 "2020-04-04T23:06:13Z")

</div>

Don’t use loop, use play

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 4, 2020, 11:07pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/8 "2020-04-04T23:07:59Z")

</div>

Hello again,

We are all learning.  
I am exploring this along with you for the first time.

I would go through the library here:  
[http://code.compartmental.net/minim/fileplayer\_class\_fileplayer.html](http://code.compartmental.net/minim/fileplayer_class_fileplayer.html)

This lets you set start time:  
[http://code.compartmental.net/minim/fileplayer\_method\_play.html](http://code.compartmental.net/minim/fileplayer_method_play.html)

I am also looking at this:  
[http://code.compartmental.net/minim/fileplayer\_method\_position.html](http://code.compartmental.net/minim/fileplayer_method_position.html)

I look forward to your choices and solution.

Update: I did not see the other responses to this when I posted it.  
Have fun!

`:)`

---

<div class="post-metadata">

**Author:** ![goingbananas](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@goingbananas](https://discourse.processing.org/u/goingbananas)\
**Post date:** [April 4, 2020, 11:24pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/9 "2020-04-04T23:24:19Z")

</div>

Yeah that’s what I thought I needed. I tried to implement cue and also tried millis. But I couldn’t make them work, don’t know why because I can’t find any examples on any forum.  
I only found the Processing example for millis, but it’s applied to a time counter and doesn’t say much about how to use it in cases like mine.

It’s so frustrating

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 4, 2020, 11:28pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/10 "2020-04-04T23:28:10Z")

</div>

…

filePlayer.play(3000);

---

<div class="post-metadata">

**Author:** ![goingbananas](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@goingbananas](https://discourse.processing.org/u/goingbananas)\
**Post date:** [April 4, 2020, 11:48pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/11 "2020-04-04T23:48:07Z")

</div>

Hey, so here [http://code.compartmental.net/minim/fileplayer\_method\_play.html](http://code.compartmental.net/minim/fileplayer_method_play.html) they’re not using play() instead they are using cue(). But they’re using it by taking the position of the mouse when it clicks to start playing.

Here’s the big deal, where I think I’m missing something big: how can I tell cue() or play() the exact milliseconds?  
I’ve tried what Chrisir said filePlayer.play(3000); but still isn’t working (by not working I mean it’s playing from the beginning). Does it need declaring something else besides (3000)?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 4, 2020, 11:51pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/12 "2020-04-04T23:51:23Z")

</div>

Still fiddling with loop() and success. 🙂

```auto
//Modified setLoopPoints in examples from Minim library

import ddf.minim.*;

Minim minim;
AudioPlayer snip;

void setup()
  {
  size(200, 200);
  minim = new Minim(this);
  snip = minim.loadFile("groove.mp3");
  println(snip.length());
  }

void draw()
  {
  background(0);
  }

void mousePressed()
  {
  if ( mouseButton == LEFT )
    {
    snip.setLoopPoints(0, 1500);
    snip.loop(0);
    }

  if ( mouseButton == CENTER )
    {
    snip.setLoopPoints(1500, 3000);
    snip.loop(0);
    }
  
  if ( mouseButton == RIGHT )
    {
    snip.setLoopPoints(3000, snip.length()/3); //I jsut can't listen to the end 16849ms!
    snip.loop(0);
    }  
  }  

```

I will try other ways another day; this was a fun distraction.  
Let us know when you have mastered this.

`:)`

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 4, 2020, 11:55pm UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/13 "2020-04-04T23:55:01Z")

</div>

Did you try …cue(3000); then?

---

<div class="post-metadata">

**Author:** ![goingbananas](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@goingbananas](https://discourse.processing.org/u/goingbananas)\
**Post date:** [April 5, 2020, 12:26am UTC](https://discourse.processing.org/t/how-can-i-start-fileplayer-from-a-given-second-new-and-going-bananas/19403/14 "2020-04-05T00:26:19Z")

</div>

That’s it. My ears hear it, my eyes see it, my code is finally working… but still can’t believe it. THANK YOU!

> I will try other ways another day; this was a fun distraction.  
> Let us know when you have mastered this.

I’m glad at least someone enjoyed, haha. But I’m afraid I have no future at all as a processing/java programmer. I’ve been stuck with this for two days, geez. But I’m all here for the learning if you want to share the future results of your exploring.

Thanks again guys
