63 lines
2.3 KiB
Java
63 lines
2.3 KiB
Java
package o;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.res.AssetFileDescriptor;
|
|
import android.media.AudioAttributes;
|
|
import android.media.MediaPlayer;
|
|
import java.io.IOException;
|
|
import o.C17083tlK;
|
|
|
|
/* renamed from: o.nKe, reason: case insensitive filesystem */
|
|
/* loaded from: classes2.dex */
|
|
public final class C16303nKe {
|
|
private final Context d;
|
|
public boolean c = true;
|
|
public boolean b = false;
|
|
|
|
public C16303nKe(Activity activity) {
|
|
activity.setVolumeControlStream(3);
|
|
this.d = activity.getApplicationContext();
|
|
}
|
|
|
|
public final MediaPlayer NK_() {
|
|
MediaPlayer mediaPlayer = new MediaPlayer();
|
|
mediaPlayer.setAudioAttributes(new AudioAttributes.Builder().setContentType(2).build());
|
|
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // from class: o.KRK
|
|
@Override // android.media.MediaPlayer.OnCompletionListener
|
|
public final void onCompletion(MediaPlayer mediaPlayer2) {
|
|
mediaPlayer2.stop();
|
|
mediaPlayer2.reset();
|
|
mediaPlayer2.release();
|
|
}
|
|
});
|
|
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { // from class: o.kWb
|
|
@Override // android.media.MediaPlayer.OnErrorListener
|
|
public final boolean onError(MediaPlayer mediaPlayer2, int i, int i2) {
|
|
mediaPlayer2.stop();
|
|
mediaPlayer2.reset();
|
|
mediaPlayer2.release();
|
|
return true;
|
|
}
|
|
});
|
|
try {
|
|
AssetFileDescriptor openRawResourceFd = this.d.getResources().openRawResourceFd(C17083tlK.Sts.zxing_beep);
|
|
try {
|
|
mediaPlayer.setDataSource(openRawResourceFd.getFileDescriptor(), openRawResourceFd.getStartOffset(), openRawResourceFd.getLength());
|
|
openRawResourceFd.close();
|
|
mediaPlayer.setVolume(0.1f, 0.1f);
|
|
mediaPlayer.prepare();
|
|
mediaPlayer.start();
|
|
return mediaPlayer;
|
|
} catch (Throwable th) {
|
|
openRawResourceFd.close();
|
|
throw th;
|
|
}
|
|
} catch (IOException unused) {
|
|
mediaPlayer.reset();
|
|
mediaPlayer.release();
|
|
return null;
|
|
}
|
|
}
|
|
}
|