package K.K.K;

import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

/* renamed from: K.K.K.K  reason: contains not printable characters */
public class C2373 {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static boolean f8217 = true;

    /* renamed from: ʬ  reason: contains not printable characters */
    public Handler f8218 = new HandlerC2376(Looper.getMainLooper());

    /* renamed from: ῲ  reason: contains not printable characters */
    public Context f8219;

    /* renamed from: K  reason: contains not printable characters */
    public MediaPlayer f8220 = new MediaPlayer();

    /* renamed from: 㸾  reason: contains not printable characters */
    public long f8221;

    /* renamed from: K.K.K.K$ʬ  reason: contains not printable characters */
    public class C2374 implements MediaPlayer.OnCompletionListener {

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ int f8223;

        public C2374(int i) {
            this.f8223 = i;
        }

        public void onCompletion(MediaPlayer mediaPlayer) {
            C2373 k = C2373.this;
            int i = this.f8223;
            if (k.f8218 != null) {
                Message obtain = Message.obtain();
                obtain.what = 1500;
                obtain.obj = Integer.valueOf(i);
                k.f8218.sendMessageDelayed(obtain, k.f8221);
            }
        }
    }

    /* renamed from: K.K.K.K$ῲ  reason: contains not printable characters */
    public class C2375 implements MediaPlayer.OnPreparedListener {
        public C2375() {
        }

        public void onPrepared(MediaPlayer mediaPlayer) {
            C2373.this.f8220.start();
        }
    }

    /* renamed from: K.K.K.K$K  reason: contains not printable characters */
    public class HandlerC2376 extends Handler {
        public HandlerC2376(Looper looper) {
            super(looper);
        }

        public void handleMessage(Message message) {
            super.handleMessage(message);
            if (message.what == 1500) {
                C2373 k = C2373.this;
                if (k.f8218 != null) {
                    k.m6359(((Integer) message.obj).intValue(), true, C2373.this.f8221);
                }
            }
        }
    }

    public C2373(Context context) {
        this.f8219 = context;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6359(int i, boolean z, long j) {
        if (this.f8220 != null && i != -1 && f8217) {
            this.f8221 = j;
            Handler handler = this.f8218;
            if (handler != null) {
                handler.removeMessages(1500);
            }
            MediaPlayer mediaPlayer = this.f8220;
            if (mediaPlayer != null) {
                mediaPlayer.reset();
            }
            try {
                AssetFileDescriptor openRawResourceFd = this.f8219.getResources().openRawResourceFd(i);
                this.f8220.setDataSource(openRawResourceFd.getFileDescriptor(), openRawResourceFd.getStartOffset(), openRawResourceFd.getLength());
                openRawResourceFd.close();
                this.f8220.setOnPreparedListener(new C2375());
                if (z) {
                    this.f8220.setOnCompletionListener(new C2374(i));
                }
                this.f8220.prepareAsync();
            } catch (Exception unused) {
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6360(boolean z) {
        f8217 = z;
        if (!f8217) {
            Handler handler = this.f8218;
            if (handler != null) {
                handler.removeMessages(1500);
            }
            MediaPlayer mediaPlayer = this.f8220;
            if (mediaPlayer != null) {
                mediaPlayer.reset();
            }
        }
    }
}
