DroidFish: Avoid crash if playing a move sound fails.

This commit is contained in:
Peter Osterlund 2013-05-13 19:27:42 +00:00
parent ffa0e1a240
commit eb00cf60de

View File

@ -81,6 +81,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.StateListDrawable;
import android.media.MediaPlayer; import android.media.MediaPlayer;
@ -3136,9 +3137,12 @@ public class DroidFish extends Activity implements GUIInterface {
if (soundEnabled) { if (soundEnabled) {
if (moveSound != null) if (moveSound != null)
moveSound.release(); moveSound.release();
moveSound = MediaPlayer.create(this, R.raw.movesound); try {
if (moveSound != null) moveSound = MediaPlayer.create(this, R.raw.movesound);
moveSound.start(); if (moveSound != null)
moveSound.start();
} catch (NotFoundException ex) {
}
} }
if (vibrateEnabled) { if (vibrateEnabled) {
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);