package g6;

import android.graphics.SurfaceTexture;
import android.media.MediaPlayer;
import android.media.PlaybackParams;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.SparseIntArray;
import android.view.Surface;
import android.view.SurfaceHolder;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import com.bytedance.sdk.component.utils.mq;
import com.bytedance.sdk.component.utils.sds;
import com.bytedance.sdk.component.utils.wey;
import com.bytedance.sdk.component.wu.fm.fm;
import com.bytedance.sdk.openadsdk.core.fhx.yz.lb;
import java.io.File;
import java.io.FileInputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import okhttp3.internal.http.StatusLine;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public abstract class o implements v5.b, a, b, c, d, e, f, g, mq.fm {
    private static final SparseIntArray fm = new SparseIntArray();
    private SurfaceHolder ajl;
    private boolean dsz;
    private boolean duv;
    private int hi;
    private ArrayList<Runnable> hlt;
    private volatile boolean hxv;
    private mq irt;
    private SurfaceTexture jnr;
    private boolean lse;
    private boolean mon;
    private boolean mq;
    private volatile boolean tzk;
    private boolean zan;
    private final boolean ro = false;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private final List<WeakReference<v5.a>> f26269lb = new CopyOnWriteArrayList();
    private final n yz = new n((lb) this);
    private int wsy = 0;
    private int wu = 3;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private boolean f26266ef = false;
    private volatile h vt = null;
    private boolean ku = false;
    private volatile int onz = 201;
    private long fhx = -1;
    private boolean qhl = false;
    private long gof = 0;
    private long gqi = Long.MIN_VALUE;
    private long wey = 0;
    private long sds = 0;
    private long maa = 0;
    private String nt = SessionDescription.SUPPORTED_SDP_VERSION;
    private com.bykv.vk.openvk.fm.fm.fm.lb.lb gzf = null;
    private boolean ai = false;
    private CountDownLatch ol = new CountDownLatch(1);
    private volatile int wbw = 200;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private AtomicBoolean f26268ha = new AtomicBoolean(false);
    private Surface pkk = null;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private long f26267gc = 0;
    private long xgn = 0;
    private final Runnable bx = new k(this, 5);

    public o() {
        int i10 = 0;
        this.hi = 0;
        this.mon = false;
        this.hi = 0;
        mq mqVarFm = fm.fm().fm(this, "csj_".concat("SSMediaPlayerWrapper"));
        this.irt = mqVarFm;
        this.mon = true;
        if (mqVarFm != null) {
            mqVarFm.post(new k(this, i10));
        }
    }

    public static void vt(o oVar) {
        mq mqVar = oVar.irt;
        if (mqVar != null) {
            mqVar.post(new k(oVar, 0));
        }
    }

    public final void a(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar, File file) {
        if (!lbVar.fm()) {
            b(file);
            return;
        }
        try {
            String strX = nb.g.x(file);
            if (lbVar.qhl().equals(strX)) {
                b(file);
                return;
            }
            JSONObject jSONObjectLb = lbVar.lb();
            boolean zRo = lbVar.ro();
            if (jSONObjectLb != null) {
                jSONObjectLb.put("file_hash", lbVar.qhl());
                jSONObjectLb.put("file_real_hash", strX);
                jSONObjectLb.put("is_change_play_type", zRo ? 1 : 0);
                jSONObjectLb.put("error_real_code", 309);
                jSONObjectLb.put("error_real_msg", "md5_not_match");
            }
            if (zRo) {
                boolean zDelete = file.delete();
                if (jSONObjectLb != null) {
                    jSONObjectLb.put("delete_cache_file", zDelete ? 1 : 0);
                }
                if (zDelete) {
                    f(lbVar);
                    return;
                }
            }
            b(file);
        } catch (Throwable unused) {
        }
    }

    public final void b(File file) {
        file.getAbsolutePath();
        try {
            if (sds.fm(v5.c.f33669a)) {
                ((j) this.vt).b(file.getAbsolutePath());
            } else {
                FileInputStream fileInputStream = new FileInputStream(file.getAbsolutePath());
                h hVar = this.vt;
                ((j) hVar).f26249i.setDataSource(fileInputStream.getFD());
                fileInputStream.close();
            }
        } catch (Throwable unused) {
        }
    }

    public final void c(Runnable runnable) {
        try {
            if (this.hlt == null) {
                this.hlt = new ArrayList<>();
            }
            this.hlt.add(runnable);
        } catch (Throwable th) {
            th.getMessage();
        }
    }

    public final void d() {
        mq mqVar = this.irt;
        if (mqVar == null || mqVar.getLooper() == null) {
            return;
        }
        try {
            this.irt.post(new k(this, 6));
        } catch (Throwable unused) {
        }
    }

    public boolean dsz() {
        return this.onz == 205;
    }

    public void duv() {
        if (wu()) {
            return;
        }
        this.dsz = true;
        ArrayList<Runnable> arrayList = this.hlt;
        if (arrayList != null && !arrayList.isEmpty()) {
            this.hlt.clear();
        }
        mq mqVar = this.irt;
        if (mqVar != null) {
            try {
                mqVar.removeCallbacksAndMessages(null);
                if (this.vt != null) {
                    this.irt.sendEmptyMessage(103);
                }
                d();
            } catch (Throwable unused) {
                d();
            }
        }
    }

    public final void e() {
        if (this.vt == null) {
            return;
        }
        try {
            j jVar = (j) this.vt;
            jVar.getClass();
            try {
                jVar.f26249i.reset();
            } catch (Throwable unused) {
            }
            d6.a aVar = jVar.f26251k;
            if (aVar != null) {
                try {
                    aVar.close();
                } catch (Throwable unused2) {
                }
                jVar.f26251k = null;
            }
            jVar.c();
            jVar.e();
        } catch (Throwable unused3) {
        }
        ((j) this.vt).f26242b = null;
        ((j) this.vt).f26245e = null;
        ((j) this.vt).f26243c = null;
        ((j) this.vt).f26247g = null;
        ((j) this.vt).f26246f = null;
        ((j) this.vt).f26241a = null;
        ((j) this.vt).f26244d = null;
        try {
            j jVar2 = (j) this.vt;
            synchronized (jVar2.f26253m) {
                try {
                    if (!jVar2.f26254n) {
                        jVar2.f26249i.release();
                        jVar2.f26254n = true;
                        jVar2.d();
                        d6.a aVar2 = jVar2.f26251k;
                        if (aVar2 != null) {
                            try {
                                aVar2.close();
                            } catch (Throwable unused4) {
                            }
                            jVar2.f26251k = null;
                        }
                        jVar2.c();
                        jVar2.e();
                    }
                } finally {
                }
            }
        } catch (Throwable unused5) {
        }
    }

    public final void f(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar) {
        lbVar.irt();
        j jVar = (j) this.vt;
        synchronized (jVar) {
            d6.a aVar = new d6.a(v5.c.f33669a, lbVar);
            d6.a.f25000e.put(lbVar.qhl(), aVar);
            jVar.f26251k = aVar;
            f6.a.a(lbVar);
            jVar.f26249i.setDataSource(jVar.f26251k);
        }
        lbVar.irt();
    }

    public long fhx() {
        if (this.qhl) {
            long j10 = this.wey;
            if (j10 > 0) {
                return this.gof + j10;
            }
        }
        return this.gof;
    }

    @Override // v5.b
    public boolean fm() {
        return this.f26266ef;
    }

    public final void g() {
        this.tzk = true;
        this.f26266ef = true;
        long jElapsedRealtime = SystemClock.elapsedRealtime() - this.maa;
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().fm(this, jElapsedRealtime);
            }
        }
    }

    public long gof() {
        if (wu()) {
            return 0L;
        }
        if (this.onz != 206 && this.onz != 207) {
            return 0L;
        }
        try {
            ((j) this.vt).getClass();
            return r0.f26249i.getCurrentPosition();
        } catch (Throwable unused) {
            return 0L;
        }
    }

    public SurfaceHolder gqi() {
        return this.ajl;
    }

    public final void h() {
        ArrayList<Runnable> arrayList = this.hlt;
        if (arrayList == null || arrayList.isEmpty() || this.duv) {
            return;
        }
        this.duv = true;
        Iterator it = new ArrayList(this.hlt).iterator();
        while (it.hasNext()) {
            ((Runnable) it.next()).run();
        }
        this.hlt.clear();
        this.duv = false;
    }

    public final void i(int i10) {
        if (i10 == 701) {
            this.f26267gc = SystemClock.elapsedRealtime();
            this.wsy++;
            for (WeakReference<v5.a> weakReference : this.f26269lb) {
                if (weakReference != null && weakReference.get() != null) {
                    weakReference.get().fm(this, Integer.MAX_VALUE, 0, 0);
                }
            }
            return;
        }
        if (i10 != 702) {
            if (this.mon && i10 == 3) {
                h();
                g();
                ro(this.ai);
                return;
            } else {
                if (i10 == 805) {
                    this.zan = true;
                    return;
                }
                return;
            }
        }
        if (this.f26267gc > 0) {
            this.xgn = (SystemClock.elapsedRealtime() - this.f26267gc) + this.xgn;
            this.f26267gc = 0L;
        }
        for (WeakReference<v5.a> weakReference2 : this.f26269lb) {
            if (weakReference2 != null && weakReference2.get() != null) {
                weakReference2.get().fm((v5.b) this, Integer.MAX_VALUE);
            }
        }
    }

    public int irt() {
        return this.wsy;
    }

    public final void j(long j10) {
        n nVar = this.yz;
        nVar.f26263a = j10;
        if (this.mq) {
            k(nVar);
            return;
        }
        com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar = this.gzf;
        if (lbVar == null || !lbVar.wsy()) {
            c(this.yz);
        } else {
            k(this.yz);
        }
    }

    public final void k(Runnable runnable) {
        if (runnable == null || wu()) {
            return;
        }
        if (this.dsz) {
            c(runnable);
        } else {
            runnable.run();
        }
    }

    public boolean onz() {
        return this.zan;
    }

    public long qhl() {
        long j10 = this.sds;
        long duration = 0;
        if (j10 != 0) {
            return j10;
        }
        if (this.onz == 206 || this.onz == 207) {
            try {
                j jVar = (j) this.vt;
                jVar.getClass();
                try {
                    duration = jVar.f26249i.getDuration();
                } catch (Throwable unused) {
                }
                this.sds = duration;
            } catch (Throwable unused2) {
            }
        }
        return this.sds;
    }

    public void ro(int i10) {
        this.wu = i10;
    }

    public SurfaceTexture wey() {
        return this.jnr;
    }

    @Override // v5.b
    public boolean wu() {
        return this.dsz;
    }

    @Override // v5.b
    public boolean ajl() {
        mq mqVar;
        return (this.onz == 206 || ((mqVar = this.irt) != null && mqVar.hasMessages(100))) && !this.hxv;
    }

    public void ef() {
        if (wu() || this.vt == null) {
            return;
        }
        this.f26268ha.set(true);
        if (this.onz != 206) {
            this.gof = 0L;
            this.wsy = 0;
            this.wey = 0L;
            this.qhl = false;
            this.gqi = Long.MIN_VALUE;
            this.hxv = false;
            this.yz.f26264b = true;
            j(0L);
            mq mqVar = this.irt;
            if (mqVar != null) {
                mqVar.removeCallbacks(this.bx);
                this.irt.postDelayed(this.bx, this.wbw);
            }
        }
        this.ol.countDown();
    }

    @Override // v5.b
    public int jnr() {
        MediaPlayer mediaPlayer;
        if (this.vt == null || wu() || (mediaPlayer = ((j) this.vt).f26249i) == null) {
            return 0;
        }
        return mediaPlayer.getVideoHeight();
    }

    public void ku() {
        mq mqVar;
        com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar;
        com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar2;
        if (wu() || (mqVar = this.irt) == null) {
            return;
        }
        mqVar.removeMessages(100);
        this.hxv = true;
        if (this.mon) {
            if (!this.f26266ef && ((lbVar = this.gzf) == null || !lbVar.wsy())) {
                c(new k(this, 3));
                return;
            }
            mq mqVar2 = this.irt;
            if (mqVar2 != null) {
                mqVar2.sendEmptyMessage(101);
                return;
            }
            return;
        }
        if (!this.lse && ((lbVar2 = this.gzf) == null || !lbVar2.wsy())) {
            c(new k(this, 2));
            return;
        }
        mq mqVar3 = this.irt;
        if (mqVar3 != null) {
            mqVar3.sendEmptyMessage(101);
        }
    }

    @Override // v5.b
    public boolean ro() {
        return this.onz == 209;
    }

    @Override // v5.b
    public boolean wsy() {
        mq mqVar;
        return ((this.onz != 207 && !this.hxv) || (mqVar = this.irt) == null || mqVar.hasMessages(100)) ? false : true;
    }

    public void vt() {
        if (wu() || this.irt == null) {
            return;
        }
        this.f26268ha.set(true);
        this.irt.post(new k(this, 1));
    }

    @Override // v5.b
    public boolean lb() {
        return dsz() || ajl() || wsy();
    }

    @Override // v5.b
    public int yz() {
        MediaPlayer mediaPlayer;
        if (this.vt == null || wu() || (mediaPlayer = ((j) this.vt).f26249i) == null) {
            return 0;
        }
        return mediaPlayer.getVideoWidth();
    }

    @Override // g6.a
    public void lb(h hVar) {
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().fm((v5.b) this, true);
            }
        }
    }

    @Override // g6.g
    public boolean ro(h hVar, int i10, int i11) {
        if (this.vt != hVar) {
            return false;
        }
        if (i11 == -1004) {
            com.bykv.vk.openvk.fm.fm.fm.lb.a aVar = new com.bykv.vk.openvk.fm.fm.fm.lb.a(i10, i11);
            for (WeakReference<v5.a> weakReference : this.f26269lb) {
                if (weakReference != null && weakReference.get() != null) {
                    weakReference.get().fm(this, aVar);
                }
            }
        }
        i(i10);
        return false;
    }

    public static void fm(o oVar, long j10, long j11) {
        if (!oVar.tzk) {
            oVar.g();
        }
        for (WeakReference<v5.a> weakReference : oVar.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().fm(oVar, j10, j11);
            }
        }
    }

    @Override // g6.c
    public void ro(h hVar) {
        if (wu()) {
            return;
        }
        this.onz = 205;
        int i10 = 1;
        try {
            com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar = this.gzf;
            if (lbVar != null) {
                float fFhx = lbVar.fhx();
                if (fFhx > 0.0f) {
                    e1.l lVar = new e1.l(i10);
                    lVar.f25430a = fFhx;
                    MediaPlayer mediaPlayer = ((j) this.vt).f26249i;
                    mediaPlayer.setPlaybackParams(mediaPlayer.getPlaybackParams().setSpeed(lVar.f25430a));
                }
            }
        } catch (Throwable unused) {
        }
        if (this.irt != null) {
            if (this.hxv) {
                mq mqVar = this.irt;
                if (mqVar != null) {
                    mqVar.post(new k(this, 7));
                }
            } else {
                mq mqVar2 = this.irt;
                mqVar2.sendMessage(mqVar2.obtainMessage(100, -1, -1));
            }
        }
        fm.delete(this.hi);
        boolean z10 = this.mon;
        boolean z11 = this.lse;
        if (!z10 && !z11) {
            g();
            this.lse = true;
        }
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().ro(this);
            }
        }
    }

    public void fm(boolean z10) {
        if (wu()) {
            return;
        }
        this.mq = z10;
        if (this.vt != null) {
            ((j) this.vt).f26248h = z10;
            return;
        }
        mq mqVar = this.irt;
        if (mqVar != null) {
            mqVar.post(new m(this, z10, 1));
        }
    }

    public void fm(boolean z10, long j10, boolean z11) {
        if (wu()) {
            return;
        }
        mq mqVar = this.irt;
        int i10 = 0;
        if (mqVar != null) {
            mqVar.post(new k(this, i10));
        }
        this.ai = z11;
        this.f26268ha.set(true);
        this.hxv = false;
        ro(z11);
        if (z10) {
            this.fhx = j10;
            k(new k(this, 4));
        } else {
            j(j10);
        }
        mq mqVar2 = this.irt;
        if (mqVar2 != null) {
            mqVar2.removeCallbacks(this.bx);
            this.irt.postDelayed(this.bx, this.wbw);
        }
        this.ol.countDown();
    }

    public void ro(boolean z10) {
        mq mqVar;
        if (wu() || (mqVar = this.irt) == null) {
            return;
        }
        mqVar.post(new m(this, z10, 0));
    }

    public void fm(long j10) {
        if (wu()) {
            return;
        }
        if (this.onz == 207 || this.onz == 206 || this.onz == 209) {
            k(new l(this, j10, 0));
        }
    }

    public void fm(SurfaceTexture surfaceTexture) {
        if (wu()) {
            return;
        }
        this.jnr = surfaceTexture;
        fm(true);
        k(new l.l(this, surfaceTexture, 14));
    }

    public void fm(SurfaceHolder surfaceHolder) {
        if (wu()) {
            return;
        }
        this.ajl = surfaceHolder;
        fm(true);
        k(new l.l(this, surfaceHolder, 15));
    }

    public void fm(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar) {
        if (wu()) {
            return;
        }
        this.gzf = lbVar;
        if (lbVar != null) {
            this.mon = this.mon && !lbVar.wsy();
        }
        k(new l.l(this, lbVar, 16));
    }

    /* JADX WARN: Removed duplicated region for block: B:121:0x0227  */
    /* JADX WARN: Removed duplicated region for block: B:182:? A[RETURN, SYNTHETIC] */
    @Override // com.bytedance.sdk.component.utils.mq.fm
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void fm(Message message) {
        int i10 = this.onz;
        int i11 = message.what;
        if (this.vt != null) {
            try {
                switch (message.what) {
                    case 100:
                        if (this.onz == 205 || this.onz == 207 || this.onz == 209) {
                            ((j) this.vt).f26249i.start();
                            this.maa = SystemClock.elapsedRealtime();
                            this.onz = 206;
                            if (this.fhx > 0) {
                                ((j) this.vt).a(this.fhx, this.wu);
                                this.fhx = -1L;
                            }
                            if (this.gzf != null) {
                                ro(this.ai);
                                return;
                            }
                            return;
                        }
                        this.onz = 200;
                        if (this.ku) {
                            com.bykv.vk.openvk.fm.fm.fm.lb.a aVar = new com.bykv.vk.openvk.fm.fm.fm.lb.a(StatusLine.HTTP_PERM_REDIRECT, i11);
                            aVar.f5920c = i10 + "," + i11;
                            for (WeakReference<v5.a> weakReference : this.f26269lb) {
                                if (weakReference != null && weakReference.get() != null) {
                                    weakReference.get().fm(this, aVar);
                                }
                            }
                            this.ku = true;
                            return;
                        }
                        return;
                    case 101:
                        if (this.qhl) {
                            this.gof += this.wey;
                        }
                        this.qhl = false;
                        this.wey = 0L;
                        this.gqi = Long.MIN_VALUE;
                        if (this.onz == 206 || this.onz == 207 || this.onz == 209) {
                            ((j) this.vt).f26249i.pause();
                            this.onz = 207;
                            this.hxv = false;
                            for (WeakReference<v5.a> weakReference2 : this.f26269lb) {
                                if (weakReference2 != null && weakReference2.get() != null) {
                                    weakReference2.get().yz(this);
                                }
                            }
                            return;
                        }
                        this.onz = 200;
                        if (this.ku) {
                        }
                        break;
                    case 102:
                        j jVar = (j) this.vt;
                        jVar.getClass();
                        try {
                            jVar.f26249i.reset();
                            break;
                        } catch (Throwable unused) {
                        }
                        d6.a aVar2 = jVar.f26251k;
                        if (aVar2 != null) {
                            try {
                                aVar2.close();
                                break;
                            } catch (Throwable unused2) {
                            }
                            jVar.f26251k = null;
                        }
                        jVar.c();
                        jVar.e();
                        this.onz = 201;
                        return;
                    case 103:
                        try {
                            e();
                            break;
                        } catch (Throwable unused3) {
                        }
                        for (WeakReference<v5.a> weakReference3 : this.f26269lb) {
                            if (weakReference3 != null && weakReference3.get() != null) {
                                weakReference3.get().lb(this);
                            }
                        }
                        this.onz = 203;
                        return;
                    case 104:
                        if (this.onz == 202 || this.onz == 208) {
                            MediaPlayer mediaPlayer = ((j) this.vt).f26249i;
                            if (mediaPlayer != null) {
                                mediaPlayer.prepareAsync();
                                return;
                            }
                            return;
                        }
                        this.onz = 200;
                        if (this.ku) {
                        }
                        break;
                    case 105:
                        if (this.onz == 205 || this.onz == 206 || this.onz == 208 || this.onz == 207 || this.onz == 209) {
                            ((j) this.vt).f26249i.stop();
                            this.onz = 208;
                            return;
                        }
                        this.onz = 200;
                        if (this.ku) {
                        }
                        break;
                    case 106:
                        if (this.onz == 206 || this.onz == 207 || this.onz == 209) {
                            ((j) this.vt).a(((Long) message.obj).longValue(), this.wu);
                            return;
                        }
                        this.onz = 200;
                        if (this.ku) {
                        }
                        break;
                    case 107:
                        this.gof = 0L;
                        this.wsy = 0;
                        this.wey = 0L;
                        this.qhl = false;
                        this.gqi = Long.MIN_VALUE;
                        if (this.onz == 201 || this.onz == 203) {
                            com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar = (com.bykv.vk.openvk.fm.fm.fm.lb.lb) message.obj;
                            if (TextUtils.isEmpty(lbVar.jnr())) {
                                if (TextUtils.isEmpty(v5.c.f33670b)) {
                                    try {
                                        File file = new File(v5.c.f33669a.getFilesDir(), "ttad_dir");
                                        if (!file.exists()) {
                                            file.mkdirs();
                                        }
                                        v5.c.f33670b = file.getAbsolutePath();
                                        break;
                                    } catch (Throwable unused4) {
                                    }
                                }
                                lbVar.fm(v5.c.f33670b);
                            }
                            if (lbVar.hi()) {
                                ((j) this.vt).b(lbVar.irt());
                                lbVar.irt();
                            } else {
                                File file2 = new File(lbVar.jnr(), lbVar.qhl());
                                if (file2.exists()) {
                                    a(lbVar, file2);
                                } else {
                                    f(lbVar);
                                }
                            }
                            this.onz = 202;
                            return;
                        }
                        this.onz = 200;
                        if (this.ku) {
                        }
                        break;
                    case 108:
                    case 109:
                    default:
                        return;
                    case 110:
                        SurfaceHolder surfaceHolder = (SurfaceHolder) message.obj;
                        j jVar2 = (j) this.vt;
                        synchronized (jVar2.f26253m) {
                            try {
                                if (!jVar2.f26254n && surfaceHolder != null && surfaceHolder.getSurface() != null && jVar2.f26248h) {
                                    jVar2.f26249i.setDisplay(surfaceHolder);
                                }
                                break;
                            } catch (Throwable unused5) {
                            }
                            break;
                        }
                        ((j) this.vt).f26249i.setScreenOnWhilePlaying(true);
                        this.ol.await(1L, TimeUnit.SECONDS);
                        h();
                        return;
                    case 111:
                        this.pkk = new Surface((SurfaceTexture) message.obj);
                        h hVar = this.vt;
                        Surface surface = this.pkk;
                        j jVar3 = (j) hVar;
                        jVar3.d();
                        jVar3.f26252l = surface;
                        jVar3.f26249i.setSurface(surface);
                        ((j) this.vt).f26249i.setScreenOnWhilePlaying(true);
                        this.ol.await(1L, TimeUnit.SECONDS);
                        h();
                        return;
                }
            } catch (Throwable unused6) {
            }
        }
    }

    @Override // g6.b
    public void fm(h hVar, int i10) {
        if (this.vt != hVar) {
            return;
        }
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().ro(this, i10);
            }
        }
    }

    @Override // g6.d
    public boolean fm(h hVar, int i10, int i11) {
        SparseIntArray sparseIntArray = fm;
        Integer numValueOf = Integer.valueOf(sparseIntArray.get(this.hi));
        if (numValueOf == null) {
            sparseIntArray.put(this.hi, 1);
        } else {
            sparseIntArray.put(this.hi, numValueOf.intValue() + 1);
        }
        this.onz = 200;
        mq mqVar = this.irt;
        if (mqVar != null) {
            mqVar.removeCallbacks(this.bx);
        }
        boolean z10 = i10 == -1010 || i10 == -1007 || i10 == -1004 || i10 == -110 || i10 == 100 || i10 == 200;
        if (i11 == 1 || i11 == 700 || i11 == 800 || z10) {
            d();
        }
        if (!this.f26268ha.get()) {
            return true;
        }
        this.f26268ha.set(false);
        com.bykv.vk.openvk.fm.fm.fm.lb.a aVar = new com.bykv.vk.openvk.fm.fm.fm.lb.a(i10, i11);
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().fm(this, aVar);
            }
        }
        return true;
    }

    @Override // g6.e
    public void fm(h hVar) {
        this.onz = 209;
        fm.delete(this.hi);
        mq mqVar = this.irt;
        if (mqVar != null) {
            mqVar.removeCallbacks(this.bx);
        }
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().fm(this);
            }
        }
    }

    @Override // g6.f
    public void fm(h hVar, int i10, int i11, int i12, int i13) {
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() != null) {
                weakReference.get().fm((v5.b) this, i10, i11);
            }
        }
    }

    public void fm(v5.a aVar) {
        if (aVar == null) {
            return;
        }
        for (WeakReference<v5.a> weakReference : this.f26269lb) {
            if (weakReference != null && weakReference.get() == aVar) {
                return;
            }
        }
        this.f26269lb.add(new WeakReference<>(aVar));
    }

    public void fm(int i10) {
        if (wu()) {
            return;
        }
        this.wbw = i10;
    }

    public boolean fm(float f10) {
        PlaybackParams playbackParams;
        if (f10 <= 0.0f) {
            return false;
        }
        try {
            if (this.vt == null || !lb()) {
                return false;
            }
            try {
                playbackParams = ((j) this.vt).f26249i.getPlaybackParams();
            } catch (Throwable th) {
                wey.lb("CSJ_VIDEO_MEDIA", "getPlaybackParams error:" + th.getMessage());
                playbackParams = null;
            }
            float speed = playbackParams != null ? playbackParams.getSpeed() : 0.0f;
            int i10 = 1;
            if (speed != f10) {
                e1.l lVar = new e1.l(i10);
                lVar.f25430a = f10;
                MediaPlayer mediaPlayer = ((j) this.vt).f26249i;
                mediaPlayer.setPlaybackParams(mediaPlayer.getPlaybackParams().setSpeed(lVar.f25430a));
            }
            return true;
        } catch (Throwable th2) {
            wey.fm("CSJ_VIDEO_MEDIA", "setPlaySpeedRatio error: ", th2);
            return false;
        }
    }
}
