/* 
 * Created on 2004/10/03 
 * Author aki@www.xucker.jpn.org 
 * License Apache2.0 or Common Public License 
 */ 
package org.jpn.xucker.commons.audio.word; 
 
import java.io.File; 
 
import org.jpn.xucker.commons.audio.FileAudioPlayer; 
import org.jpn.xucker.commons.audio.JavaSoundAudioPlayer; 
 
/** 
 *  
 * 
 */ 
public class LocalFileWordPlayer extends AbstractWordPlayer{ 
 
    private String baseDirectoryPath; 
    private FileAudioPlayer player; 
    LocalFileWordFinder finder; 
    public static final int BOTH=0; 
    public static final int ALPHABET=1; 
    public static final int PLAIN=2; 
    private int mode; 
     
     
     
    public LocalFileWordPlayer(String path){ 
        this.baseDirectoryPath=path; 
        this.player=new JavaSoundAudioPlayer(); 
        this.finder=new LocalFilePlainWordFinder(); 
    } 
     
    public LocalFileWordPlayer(String path,FileAudioPlayer player,LocalFileWordFinder finder){ 
        this.baseDirectoryPath=path; 
        this.player=player; 
        this.finder=finder; 
    } 
     
    public FileAudioPlayer getPlayer() { 
        return player; 
    } 
    public void setPlayer(FileAudioPlayer player) { 
        this.player = player; 
    } 
    /* (non-Javadoc) 
     * @see org.jpn.xucker.commons.audio.sp.WordAudioPlayer#play(java.lang.String) 
     */ 
    public void play(String word) { 
    File file=getWordFile(word); 
    if(file.exists() && player!=null){ 
        player.play(file); 
    } 
    } 
 
    /* (non-Javadoc) 
     * @see org.jpn.xucker.commons.audio.sp.WordAudioPlayer#exist(java.lang.String) 
     */ 
     
    private File getWordFile(String word){ 
         
         
        return finder.getFile(baseDirectoryPath,word); 
    } 
    public boolean exist(String word) { 
        File file=getWordFile(word); 
        return file!=null && file.exists(); 
    } 
     
    public void setBaseDirectoryPath(String path){ 
        this.baseDirectoryPath=path; 
    } 
 
    public int getMode() { 
        return mode; 
    } 
    public void setMode(int mode) { 
        this.mode = mode; 
    } 
 
    
}
    
    |