package com.fyber.inneractive.sdk.player.controller; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.SurfaceTexture; import android.os.Handler; import android.view.Surface; import android.view.TextureView; import com.fyber.inneractive.sdk.player.c; import com.fyber.inneractive.sdk.player.mediaplayer.a; import com.fyber.inneractive.sdk.util.IAlog; import java.util.Iterator; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; /* loaded from: classes2.dex */ public abstract class i implements a.k { public final Context a; public f d; public c f; public boolean g; public final Handler i; public TextureView j; public SurfaceTexture k; public Surface l; public com.fyber.inneractive.sdk.player.controller.f m; public boolean o; public com.fyber.inneractive.sdk.player.enums.b e = com.fyber.inneractive.sdk.player.enums.b.Idle; public boolean n = false; public final CopyOnWriteArrayList b = new CopyOnWriteArrayList(); public final CopyOnWriteArrayList c = new CopyOnWriteArrayList(); public com.fyber.inneractive.sdk.player.d h = new com.fyber.inneractive.sdk.player.d(this); public class a implements Runnable { public final /* synthetic */ int a; public a(int i) { this.a = i; } @Override // java.lang.Runnable public final void run() { try { Iterator it = i.this.c.iterator(); while (it.hasNext()) { ((d) it.next()).a(this.a); } } catch (Exception e) { if (IAlog.a <= 3) { i iVar = i.this; iVar.getClass(); IAlog.a("%sonPlayerProgress callback threw an exception!", e, IAlog.a(iVar)); } } } } public class b implements Runnable { public final /* synthetic */ com.fyber.inneractive.sdk.player.enums.b a; public b(com.fyber.inneractive.sdk.player.enums.b bVar) { this.a = bVar; } /* JADX WARN: Code restructure failed: missing block: B:21:0x003c, code lost: if (r1.getParent() != null) goto L40; */ /* JADX WARN: Code restructure failed: missing block: B:22:0x0076, code lost: ((android.view.ViewGroup) r6.b.j.getParent()).removeView(r6.b.j); */ /* JADX WARN: Code restructure failed: missing block: B:43:0x0074, code lost: if (r1.getParent() != null) goto L40; */ @Override // java.lang.Runnable /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final void run() { /* r6 = this; r0 = 0 com.fyber.inneractive.sdk.player.controller.i r1 = com.fyber.inneractive.sdk.player.controller.i.this // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e java.util.concurrent.CopyOnWriteArrayList r1 = r1.b // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e java.util.Iterator r1 = r1.iterator() // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e L9: boolean r2 = r1.hasNext() // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e if (r2 == 0) goto L20 java.lang.Object r2 = r1.next() // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e com.fyber.inneractive.sdk.player.controller.i$e r2 = (com.fyber.inneractive.sdk.player.controller.i.e) r2 // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e com.fyber.inneractive.sdk.player.enums.b r3 = r6.a // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e r2.a(r3) // Catch: java.lang.Throwable -> L1b java.lang.Exception -> L1e goto L9 L1b: r1 = move-exception goto L8e L1e: r1 = move-exception goto L3f L20: com.fyber.inneractive.sdk.player.enums.b r1 = r6.a com.fyber.inneractive.sdk.player.enums.b r2 = com.fyber.inneractive.sdk.player.enums.b.Idle if (r1 == r2) goto L2e com.fyber.inneractive.sdk.player.enums.b r2 = com.fyber.inneractive.sdk.player.enums.b.Error if (r1 == r2) goto L2e com.fyber.inneractive.sdk.player.enums.b r2 = com.fyber.inneractive.sdk.player.enums.b.Completed if (r1 != r2) goto L8d L2e: com.fyber.inneractive.sdk.player.controller.i r1 = com.fyber.inneractive.sdk.player.controller.i.this android.graphics.SurfaceTexture r2 = r1.k if (r2 == 0) goto L87 android.view.TextureView r1 = r1.j if (r1 == 0) goto L87 android.view.ViewParent r1 = r1.getParent() if (r1 == 0) goto L87 goto L76 L3f: int r2 = com.fyber.inneractive.sdk.util.IAlog.a // Catch: java.lang.Throwable -> L1b r3 = 3 if (r2 > r3) goto L58 java.lang.String r2 = "%sonPlayerStateChanged callback threw an exception!" r3 = 1 java.lang.Object[] r3 = new java.lang.Object[r3] // Catch: java.lang.Throwable -> L1b com.fyber.inneractive.sdk.player.controller.i r4 = com.fyber.inneractive.sdk.player.controller.i.this // Catch: java.lang.Throwable -> L1b r4.getClass() // Catch: java.lang.Throwable -> L1b java.lang.String r4 = com.fyber.inneractive.sdk.util.IAlog.a(r4) // Catch: java.lang.Throwable -> L1b r5 = 0 r3[r5] = r4 // Catch: java.lang.Throwable -> L1b com.fyber.inneractive.sdk.util.IAlog.a(r2, r1, r3) // Catch: java.lang.Throwable -> L1b L58: com.fyber.inneractive.sdk.player.enums.b r1 = r6.a com.fyber.inneractive.sdk.player.enums.b r2 = com.fyber.inneractive.sdk.player.enums.b.Idle if (r1 == r2) goto L66 com.fyber.inneractive.sdk.player.enums.b r2 = com.fyber.inneractive.sdk.player.enums.b.Error if (r1 == r2) goto L66 com.fyber.inneractive.sdk.player.enums.b r2 = com.fyber.inneractive.sdk.player.enums.b.Completed if (r1 != r2) goto L8d L66: com.fyber.inneractive.sdk.player.controller.i r1 = com.fyber.inneractive.sdk.player.controller.i.this android.graphics.SurfaceTexture r2 = r1.k if (r2 == 0) goto L87 android.view.TextureView r1 = r1.j if (r1 == 0) goto L87 android.view.ViewParent r1 = r1.getParent() if (r1 == 0) goto L87 L76: com.fyber.inneractive.sdk.player.controller.i r1 = com.fyber.inneractive.sdk.player.controller.i.this android.view.TextureView r1 = r1.j android.view.ViewParent r1 = r1.getParent() android.view.ViewGroup r1 = (android.view.ViewGroup) r1 com.fyber.inneractive.sdk.player.controller.i r2 = com.fyber.inneractive.sdk.player.controller.i.this android.view.TextureView r2 = r2.j r1.removeView(r2) L87: com.fyber.inneractive.sdk.player.controller.i r1 = com.fyber.inneractive.sdk.player.controller.i.this r1.j = r0 r1.k = r0 L8d: return L8e: com.fyber.inneractive.sdk.player.enums.b r2 = r6.a com.fyber.inneractive.sdk.player.enums.b r3 = com.fyber.inneractive.sdk.player.enums.b.Idle if (r2 == r3) goto L9c com.fyber.inneractive.sdk.player.enums.b r3 = com.fyber.inneractive.sdk.player.enums.b.Error if (r2 == r3) goto L9c com.fyber.inneractive.sdk.player.enums.b r3 = com.fyber.inneractive.sdk.player.enums.b.Completed if (r2 != r3) goto Lc3 L9c: com.fyber.inneractive.sdk.player.controller.i r2 = com.fyber.inneractive.sdk.player.controller.i.this android.graphics.SurfaceTexture r3 = r2.k if (r3 == 0) goto Lbd android.view.TextureView r2 = r2.j if (r2 == 0) goto Lbd android.view.ViewParent r2 = r2.getParent() if (r2 == 0) goto Lbd com.fyber.inneractive.sdk.player.controller.i r2 = com.fyber.inneractive.sdk.player.controller.i.this android.view.TextureView r2 = r2.j android.view.ViewParent r2 = r2.getParent() android.view.ViewGroup r2 = (android.view.ViewGroup) r2 com.fyber.inneractive.sdk.player.controller.i r3 = com.fyber.inneractive.sdk.player.controller.i.this android.view.TextureView r3 = r3.j r2.removeView(r3) Lbd: com.fyber.inneractive.sdk.player.controller.i r2 = com.fyber.inneractive.sdk.player.controller.i.this r2.j = r0 r2.k = r0 Lc3: throw r1 */ throw new UnsupportedOperationException("Method not decompiled: com.fyber.inneractive.sdk.player.controller.i.b.run():void"); } } public interface c { } public interface d { void a(int i); } public interface e { void a(com.fyber.inneractive.sdk.player.enums.b bVar); void a(Exception exc); void c(boolean z); void e(); } public interface f { } public i(Context context) { this.a = context.getApplicationContext(); this.i = new Handler(context.getMainLooper()); a(true); } public abstract void a(Surface surface); public abstract void a(String str, int i); public abstract void a(boolean z); public abstract boolean a(); @SuppressLint({"NewApi"}) public abstract void b(); public abstract void b(int i); public abstract void b(boolean z); public abstract int c(); public abstract int d(); public abstract void d(boolean z); public abstract Bitmap e(); public abstract String f(); public abstract int g(); public abstract int h(); public abstract boolean i(); public boolean j() { return this.e == com.fyber.inneractive.sdk.player.enums.b.Playing; } public abstract void k(); public abstract void l(); public final void c(boolean z) { com.fyber.inneractive.sdk.measurement.d dVar; c cVar = this.f; if (cVar == null || (dVar = ((c.a) cVar).a.h) == null) { return; } if (z) { if (dVar.c == null || !dVar.d) { return; } IAlog.a("%s mute", "OMVideo"); try { dVar.c.volumeChange(0.0f); return; } catch (Throwable th) { dVar.a(th); return; } } if (dVar.c == null || !dVar.d) { return; } IAlog.a("%s unMute", "OMVideo"); try { dVar.c.volumeChange(1.0f); } catch (Throwable th2) { dVar.a(th2); } } public final void a(com.fyber.inneractive.sdk.player.ui.f fVar) { TextureView textureView = this.j; if (textureView != fVar) { if (textureView != null) { textureView.setSurfaceTextureListener(null); } this.j = fVar; if (this.m == null) { this.m = new com.fyber.inneractive.sdk.player.controller.f(this); } if (fVar != null) { fVar.setSurfaceTextureListener(this.m); } if (this.k != null) { IAlog.a("%scalling setSurfaceTexture with cached texture", IAlog.a(this)); if (this.j.getSurfaceTexture() != null && this.j.getSurfaceTexture().equals(this.k)) { IAlog.a("%scalling setSurfaceTexture with cached texture failed", IAlog.a(this)); } else { IAlog.a("%scalling setSurfaceTexture with cached texture success", IAlog.a(this)); this.j.setSurfaceTexture(this.k); } } } } public static void a(i iVar, SurfaceTexture surfaceTexture) { boolean z = !surfaceTexture.equals(iVar.k); iVar.k = surfaceTexture; if (iVar.l == null || z) { iVar.l = new Surface(iVar.k); } iVar.a(iVar.l); } public void a(int i) { this.i.post(new a(i)); } public final void a(com.fyber.inneractive.sdk.player.enums.b bVar) { com.fyber.inneractive.sdk.player.d dVar; ScheduledThreadPoolExecutor scheduledThreadPoolExecutor; if (bVar == this.e) { return; } this.e = bVar; if (bVar == com.fyber.inneractive.sdk.player.enums.b.Playing) { com.fyber.inneractive.sdk.player.d dVar2 = this.h; if (dVar2 != null && dVar2.b == null) { ScheduledThreadPoolExecutor scheduledThreadPoolExecutor2 = new ScheduledThreadPoolExecutor(1); dVar2.b = scheduledThreadPoolExecutor2; scheduledThreadPoolExecutor2.scheduleAtFixedRate(dVar2.c, 100, 1000, TimeUnit.MILLISECONDS); } } else if ((bVar == com.fyber.inneractive.sdk.player.enums.b.Paused || bVar == com.fyber.inneractive.sdk.player.enums.b.Idle || bVar == com.fyber.inneractive.sdk.player.enums.b.Completed) && (dVar = this.h) != null && (scheduledThreadPoolExecutor = dVar.b) != null) { scheduledThreadPoolExecutor.shutdownNow(); dVar.b = null; } this.i.post(new b(bVar)); } }