All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.gluebooster.java.booster.basic.audio.RunnableClip Maven / Gradle / Ivy

Go to download

Basic classes to support the development of applications. There should be as few dependencies on other frameworks as possible.

The newest version!
package net.sf.gluebooster.java.booster.basic.audio;

import javax.sound.sampled.Clip;

import net.sf.gluebooster.java.booster.essentials.eventsCommands.CallableAbstraction;
import net.sf.gluebooster.java.booster.essentials.objects.BoostedRunnable;


/**
 * A Clip as runnable.
 * @author CBauer
 *
 */
public class RunnableClip extends CallableAbstraction {

	/**
	 * The clip to run.
	 */
	private Clip clip;
	 
	/**
	 * The position within the playing (in microseconds) at which the running
	 * should start.
	 */
	private long microsecondsPosition = 0;

	/**
	 * @Getter
	 */
	public Clip getClip() {
		return clip;
	} 

	/**
	 * @Setter
	 */
	public void setClip(Clip clip) {
		this.clip = clip;
	}

	public RunnableClip() {

	}
	/**
	 * Constructor with clip.
	 * @param clip
	 */
	public RunnableClip(Clip clip) {
		super();
		this.clip = clip;
	}


	/**
	 * Stops the clip.
	 */
	@Override
	public void stop() {
		clip.stop();
		
	}

	/**
	 * @Getter
	 */
	public long getMicrosecondsPosition() {
		return microsecondsPosition;
	}

	/**
	 * @Setter
	 */
	public void setMicrosecondsPosition(long microsecondsPosition) {
		this.microsecondsPosition = microsecondsPosition;
	}

	/**
	 * Plays the clip from a given microseconds position. This methods ends when the clip has been played up to the end.
	 * 
	 */
	@Override
	protected Void callImpl(Void... parameters) throws Exception {
		clip.setMicrosecondPosition(microsecondsPosition);
		clip.start();
		return null;
	}
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy