/*
Tiamat - a role-playing game framework
AudioPlayerFactory.java - Abstract factory to select an appropriate AudioPlayer for a given file
 
 Copyright  (C) 2004-2005 Hugues Johnson
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

package com.huguesjohnson.tiamat.audio;

import com.huguesjohnson.tiamat.audio.AudioPlayer;
import com.huguesjohnson.tiamat.audio.MidiPlayer;
import com.huguesjohnson.tiamat.audio.UnsupportedAudioFormatException;

/** AudioPlayerFactory - Abstract factory to select an appropriate AudioPlayer for a given file
 * @author Hugues Johnson
 */
public abstract class AudioPlayerFactory{
    /**
     * Chooses an appropriate AudioPlayer for the given file, throws UnsupportedAudioFormatException if one can not be found.
    * @param path The full path of the file to play.
     * @return An instance of AudioPlayer that can play the file.
     * @throws UnsupportedAudioFormatException If an AudioPlayer can not be found for the file.
     */
    public final static AudioPlayer getAudioPlayerFor(String path) throws UnsupportedAudioFormatException{
        String lpath=path.toLowerCase();
    	if(lpath.endsWith(".mid")||lpath.endsWith(".midi")){
    		return(new MidiPlayer());
    	} 
		throw(new UnsupportedAudioFormatException());
    }
}