package com.tencent.mm.plugin.collect.model;

import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.os.Looper;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.ytcommon.BuildConfig;

class g$a {
    /* JADX WARNING: Removed duplicated region for block: B:34:0x011d A:{SYNTHETIC, Splitter:B:34:0x011d} */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x011d A:{SYNTHETIC, Splitter:B:34:0x011d} */
    public static android.media.MediaPlayer a(android.content.Context r11, android.media.MediaPlayer.OnCompletionListener r12, android.media.MediaPlayer.OnErrorListener r13) {
        /*
        r6 = 2131298396; // 0x7f09085c float:1.8214764E38 double:1.0530013185E-314;
        r5 = 2;
        r10 = 40945; // 0x9ff1 float:5.7376E-41 double:2.02295E-319;
        r7 = 1;
        r8 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r10);
        if (r11 != 0) goto L_0x0026;
    L_0x000e:
        r0 = "MicroMsg.F2fRcvVoiceListener";
        r1 = "play Err context:%s pathId:%d";
        r2 = new java.lang.Object[r5];
        r2[r8] = r11;
        r3 = java.lang.Integer.valueOf(r6);
        r2[r7] = r3;
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1, r2);
        r0 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
    L_0x0025:
        return r0;
    L_0x0026:
        r9 = r11.getString(r6);
        r0 = new android.media.MediaPlayer;
        r0.<init>();
        r1 = 3;
        r0.setAudioStreamType(r1);
        r1 = "MicroMsg.F2fRcvVoiceListener";
        r2 = "play start mp:%d path:%s context:%s pathId:%d";
        r3 = 4;
        r3 = new java.lang.Object[r3];
        r4 = r0.hashCode();
        r4 = java.lang.Integer.valueOf(r4);
        r3[r8] = r4;
        r3[r7] = r9;
        r3[r5] = r11;
        r4 = 3;
        r5 = java.lang.Integer.valueOf(r6);
        r3[r4] = r5;
        com.tencent.mm.sdk.platformtools.ab.i(r1, r2, r3);
        r2 = 0;
        r1 = r11.getAssets();	 Catch:{ Exception -> 0x00d4, all -> 0x0119 }
        r6 = r1.openFd(r9);	 Catch:{ Exception -> 0x00d4, all -> 0x0119 }
        r1 = r6.getFileDescriptor();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r2 = r6.getStartOffset();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r4 = r6.getLength();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r0.setDataSource(r1, r2, r4);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r1 = 0;
        r0.setLooping(r1);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r1 = new com.tencent.mm.plugin.collect.model.g$a$1;	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r1.<init>(r0, r13);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r0.setOnErrorListener(r1);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r1 = new com.tencent.mm.plugin.collect.model.g$a$2;	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r1.<init>(r9, r0, r12);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r0.setOnCompletionListener(r1);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r0.prepare();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r0.start();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r2 = "MicroMsg.F2fRcvVoiceListener";
        r3 = "play start mp finish [%d], myLooper[%b] mainLooper[%b]";
        r1 = 3;
        r4 = new java.lang.Object[r1];	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r1 = 0;
        r5 = r0.hashCode();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r5 = java.lang.Integer.valueOf(r5);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r4[r1] = r5;	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r5 = 1;
        r1 = android.os.Looper.myLooper();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        if (r1 == 0) goto L_0x00c3;
    L_0x00a1:
        r1 = r7;
    L_0x00a2:
        r1 = java.lang.Boolean.valueOf(r1);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r4[r5] = r1;	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r5 = 2;
        r1 = android.os.Looper.getMainLooper();	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        if (r1 == 0) goto L_0x00c5;
    L_0x00af:
        r1 = r7;
    L_0x00b0:
        r1 = java.lang.Boolean.valueOf(r1);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        r4[r5] = r1;	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3, r4);	 Catch:{ Exception -> 0x0136, all -> 0x0131 }
        if (r6 == 0) goto L_0x00be;
    L_0x00bb:
        r6.close();	 Catch:{ IOException -> 0x00c7 }
    L_0x00be:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        goto L_0x0025;
    L_0x00c3:
        r1 = r8;
        goto L_0x00a2;
    L_0x00c5:
        r1 = r8;
        goto L_0x00b0;
    L_0x00c7:
        r1 = move-exception;
        r2 = "MicroMsg.F2fRcvVoiceListener";
        r3 = "";
        r4 = new java.lang.Object[r8];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r2, r1, r3, r4);
        goto L_0x00be;
    L_0x00d4:
        r1 = move-exception;
    L_0x00d5:
        r3 = "MicroMsg.F2fRcvVoiceListener";
        r4 = "play failed pathId:%d e:%s";
        r5 = 2;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x0133 }
        r6 = 0;
        r7 = 2131298396; // 0x7f09085c float:1.8214764E38 double:1.0530013185E-314;
        r7 = java.lang.Integer.valueOf(r7);	 Catch:{ all -> 0x0133 }
        r5[r6] = r7;	 Catch:{ all -> 0x0133 }
        r6 = 1;
        r7 = r1.getMessage();	 Catch:{ all -> 0x0133 }
        r5[r6] = r7;	 Catch:{ all -> 0x0133 }
        com.tencent.mm.sdk.platformtools.ab.e(r3, r4, r5);	 Catch:{ all -> 0x0133 }
        r3 = "MicroMsg.F2fRcvVoiceListener";
        r4 = "";
        r5 = 0;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x0133 }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r3, r1, r4, r5);	 Catch:{ all -> 0x0133 }
        r0.release();	 Catch:{ all -> 0x0133 }
        if (r2 == 0) goto L_0x0106;
    L_0x0103:
        r2.close();	 Catch:{ IOException -> 0x010c }
    L_0x0106:
        r0 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        goto L_0x0025;
    L_0x010c:
        r0 = move-exception;
        r1 = "MicroMsg.F2fRcvVoiceListener";
        r2 = "";
        r3 = new java.lang.Object[r8];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);
        goto L_0x0106;
    L_0x0119:
        r0 = move-exception;
        r6 = r2;
    L_0x011b:
        if (r6 == 0) goto L_0x0120;
    L_0x011d:
        r6.close();	 Catch:{ IOException -> 0x0124 }
    L_0x0120:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        throw r0;
    L_0x0124:
        r1 = move-exception;
        r2 = "MicroMsg.F2fRcvVoiceListener";
        r3 = "";
        r4 = new java.lang.Object[r8];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r2, r1, r3, r4);
        goto L_0x0120;
    L_0x0131:
        r0 = move-exception;
        goto L_0x011b;
    L_0x0133:
        r0 = move-exception;
        r6 = r2;
        goto L_0x011b;
    L_0x0136:
        r1 = move-exception;
        r2 = r6;
        goto L_0x00d5;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.collect.model.g$a.a(android.content.Context, android.media.MediaPlayer$OnCompletionListener, android.media.MediaPlayer$OnErrorListener):android.media.MediaPlayer");
    }

    public static MediaPlayer a(String str, OnCompletionListener onCompletionListener, OnErrorListener onErrorListener) {
        AppMethodBeat.i(40946);
        MediaPlayer mediaPlayer = new MediaPlayer();
        mediaPlayer.setAudioStreamType(3);
        ab.i("MicroMsg.F2fRcvVoiceListener", "play start mp:%d path:%s", new Object[]{Integer.valueOf(mediaPlayer.hashCode()), str});
        try {
            mediaPlayer.setDataSource(str);
            mediaPlayer.setLooping(false);
            mediaPlayer.setOnErrorListener(new 3(mediaPlayer, onErrorListener));
            mediaPlayer.setOnCompletionListener(new 4(str, mediaPlayer, onCompletionListener));
            mediaPlayer.prepare();
            mediaPlayer.start();
            String str2 = "MicroMsg.F2fRcvVoiceListener";
            String str3 = "play start mp finish [%d], myLooper[%b] mainLooper[%b]";
            Object[] objArr = new Object[3];
            objArr[0] = Integer.valueOf(mediaPlayer.hashCode());
            objArr[1] = Boolean.valueOf(Looper.myLooper() != null);
            objArr[2] = Boolean.valueOf(Looper.getMainLooper() != null);
            ab.i(str2, str3, objArr);
            AppMethodBeat.o(40946);
            return mediaPlayer;
        } catch (Exception e) {
            ab.e("MicroMsg.F2fRcvVoiceListener", "play failed path:%s e:%s", new Object[]{str, e.getMessage()});
            ab.printErrStackTrace("MicroMsg.F2fRcvVoiceListener", e, BuildConfig.FLAVOR, new Object[0]);
            mediaPlayer.release();
            AppMethodBeat.o(40946);
            return null;
        }
    }
}
