/**
 * MP3 Player class
 * 
 * Uses the JLayer 1.0's Player class for MP3 playback
 * Creates a Player object, and plays it using MP3PlayerThread 
 * 
 * Created by Philip Peng
 * Last updated: 2007/10/09
 * 
 * JLayer website:
 * http://www.javazoom.net/javalayer/sources.html
 * 
 */

import javazoom.jl.player.*;
import java.io.*;

public class MP3Player {

	Player player;
	MP3PlayerThread thread;
	InputStream input;
	int position = 0;
	
	/**
	 * Sets up a JLayer Player for file argument
	 */
	public MP3Player (String filename) {
		// Set up player
		try {
			input = new FileInputStream(filename);
			player = new Player(input);
			thread = new MP3PlayerThread(player);
		} catch ( Exception e ) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Starts Player playback
	 */
	public void start() {
		thread.start();
	}
	
	/**
	 * Returns Player position
	 */
	public int getPosition() {
		position = player.getPosition();
		return position;
	}
	
	/**
	 * Returns Player complete status
	 */
	public boolean isComplete() {
		return player.isComplete();
	}
	
}
