All pastes #347909 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-02-09 20:04 UTC
rendered paste body
public class Player {	private PlayProcess process = new PlayProcess();	private MusicClip clip;	public Player() {	}	public void setClip(MusicClip clip) {		if (isPlaying()) {			stop();		}		this.clip = clip;		process.setClip(clip);	}	public MusicClip getClip() {		return clip;	}	public void play() {		process.start();	}	public void stop() {		process.stop();	}	public boolean isPlaying() {		return process.playing;	}	private static class PlayProcess implements Runnable {		private Thread thread = new Thread(this);		private MusicClip clip;		private boolean playing;		public void setClip(MusicClip clip) {			this.clip = clip;		}		public void start() {			if (playing) {				return;			}			playing = true;			thread.start();		}		public void stop() {			playing = false;			clip = null;		}		public void run() {			while (playing) {				// play clip			}		}	}}