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

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:

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! :pray:

1 Like

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

Hello,

I have not yet tried this:
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:

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

:)

1 Like

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

1 Like

http://code.compartmental.net/minim/fileplayer_method_cue.html

you can also use 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

1 Like

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 :face_with_head_bandage:

2 Likes

Don’t use loop, use play

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

This lets you set start time:
http://code.compartmental.net/minim/fileplayer_method_play.html

I am also looking at this:
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!

:)

1 Like

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

filePlayer.play(3000);

Hey, so here 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)?

1 Like

Still fiddling with loop() and success. :slight_smile:

//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.

:)

1 Like

Did you try …cue(3000); then?

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

2 Likes