Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to use GImageButton1 to turn my audio file on/off with loops?

$
0
0

This is my GUI BUTTON: I want to use it to play/pause my audio file:

public void imgButton1_click1(GImageButton source, GEvent event) { //_CODE_:imgButton1:842456:
  println("imgButton1 - GImageButton >> GEvent." + event + " @ " + millis());
  imgButton1 = source;
  if (playing == true)
    {
    myplayer.play();
    }
  else
    {
    myplayer.pause();
  }
} //_CODE_:imgButton1:842456:

This is where it is in my code:

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

//declarations
Minim minim; // audio
AudioPlayer myplayer; // audio output device
boolean playing = false;

void setup()
{
  createGUI();
  minim = new Minim(this); // instantiate the audio class
  myplayer = minim.loadFile("subbeat.wav");

  myplayer.play();
  myplayer.pause();
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles