MediaPlayer mPlayer = new MediaPlayer();
private String currentSound="";
public void playSound(String source, String file){
Log.e(YummyPadApplication.TAG, "playSound source:"+source+" file:"+file+" current_mode:"+current_mode);
AudioManager audiomanage = (AudioManager) ACT_FramePage.this.getSystemService(Context.AUDIO_SERVICE);
if(audiomanage.getRingerMode()!=AudioManager.RINGER_MODE_SILENT
&& audiomanage.getRingerMode()!=AudioManager.RINGER_MODE_VIBRATE){
if(current_mode.equalsIgnoreCase(source)||
("statusbar".equalsIgnoreCase(source)&& (current_mode.equalsIgnoreCase("list")||current_mode.equalsIgnoreCase("full")))){
try {
if (currentSound.equalsIgnoreCase(file)) {
mPlayer.start();
}else{
mPlayer.reset();
mPlayer.setDataSource(Configuration.getResourcePath() + file);
mPlayer.prepare();
mPlayer.start();
currentSound=file;
}
} catch (IOException e) {
Log.e(YummyPadApplication.TAG, "prepare() failed");
}
}
}
}