package com.fyber.inneractive.sdk.player; import android.os.Handler; import android.os.Looper; import android.view.View; import com.fyber.inneractive.sdk.config.global.s; import com.fyber.inneractive.sdk.external.InneractiveAdRequest; import com.fyber.inneractive.sdk.external.InneractiveErrorCode; import com.fyber.inneractive.sdk.external.InneractiveInfrastructureError; import com.fyber.inneractive.sdk.external.InneractiveVideoError; import com.fyber.inneractive.sdk.flow.g0; import com.fyber.inneractive.sdk.flow.m; import com.fyber.inneractive.sdk.flow.o; import com.fyber.inneractive.sdk.model.vast.q; import com.fyber.inneractive.sdk.network.m0; import com.fyber.inneractive.sdk.network.n0; import com.fyber.inneractive.sdk.network.s; import com.fyber.inneractive.sdk.player.a; import com.fyber.inneractive.sdk.player.controller.i; import com.fyber.inneractive.sdk.util.IAlog; import com.fyber.inneractive.sdk.util.b; import com.fyber.inneractive.sdk.util.r; import java.util.Iterator; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class h implements g { public final com.fyber.inneractive.sdk.player.a a; public final InneractiveAdRequest b; public final com.fyber.inneractive.sdk.response.g c; public final b d; public q e; public a.InterfaceC0079a f; public boolean g = false; public final s h; public static /* synthetic */ class a { public static final /* synthetic */ int[] a; static { int[] iArr = new int[InneractiveVideoError.Error.values().length]; a = iArr; try { iArr[InneractiveVideoError.Error.ERROR_NO_MEDIA_FILES.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { a[InneractiveVideoError.Error.ERROR_FAILED_PLAYING_MEDIA_FILE.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { a[InneractiveVideoError.Error.ERROR_FAILED_PLAYING_ALL_MEDIA_FILES.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { a[InneractiveVideoError.Error.ERROR_PRE_BUFFER_TIMEOUT.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } try { a[InneractiveVideoError.Error.ERROR_BUFFER_TIMEOUT.ordinal()] = 5; } catch (NoSuchFieldError unused5) { } } } public interface b { } public h(com.fyber.inneractive.sdk.response.g gVar, InneractiveAdRequest inneractiveAdRequest, g0 g0Var, b bVar) { this.b = inneractiveAdRequest; this.c = gVar; this.d = bVar; this.h = g0Var.b(); this.a = new com.fyber.inneractive.sdk.player.a(g0Var); } public final a.InterfaceC0079a b() { return this.f; } public final void a() { e eVar; com.fyber.inneractive.sdk.player.a aVar = this.a; if (aVar == null || (eVar = aVar.b) == null) { return; } eVar.o = true; IAlog.a("IAMediaPlayerFlowManager: destroy", new Object[0]); View c = eVar.c(); if (c != null && (c instanceof com.fyber.inneractive.sdk.web.h)) { ((com.fyber.inneractive.sdk.web.h) c).destroy(); } r rVar = eVar.l; if (rVar != null) { rVar.b(); rVar.h = null; eVar.m = null; } i iVar = eVar.b; if (iVar != null) { iVar.b(); eVar.b = null; } eVar.k = null; eVar.r = null; m mVar = eVar.z; if (mVar != null) { Iterator it = mVar.l.iterator(); while (it.hasNext()) { com.fyber.inneractive.sdk.flow.vast.a next = it.next(); if (next.b != null && (next instanceof com.fyber.inneractive.sdk.flow.vast.e)) { next.a(); } } mVar.m.a(); n0 n0Var = mVar.h; if (n0Var != null) { n0Var.a = true; } m0 m0Var = mVar.i; if (m0Var != null) { m0Var.a = true; } eVar.z = null; } com.fyber.inneractive.sdk.player.ui.remote.g gVar = eVar.B; if (gVar != null) { gVar.a.a(); } } public final void c() { a.InterfaceC0079a interfaceC0079a = this.f; if (interfaceC0079a == null) { b bVar = this.d; InneractiveInfrastructureError inneractiveInfrastructureError = new InneractiveInfrastructureError(InneractiveErrorCode.SDK_INTERNAL_ERROR, com.fyber.inneractive.sdk.flow.g.COULD_NOT_LOAD_USING_FLOW_MANAGER, new Exception("loadNextMediaFile flowManager is null")); o oVar = (o) bVar; oVar.b(inneractiveInfrastructureError); oVar.a(inneractiveInfrastructureError); return; } q qVar = this.e; e eVar = (e) interfaceC0079a; eVar.r = this; if (qVar != null) { String str = qVar.g; eVar.t = qVar; eVar.q++; eVar.n = false; eVar.p = false; eVar.c = str; IAlog.a("IAMediaPlayerFlowManager: playNextMediaFile - loading video url: %s", str); r rVar = eVar.l; if (rVar != null) { rVar.b(); rVar.h = null; eVar.m = null; } if (eVar.m == null) { eVar.m = new com.fyber.inneractive.sdk.player.b(eVar); } IAlog.a("IAMediaPlayerFlowManager: start - start fetching video frame", new Object[0]); if (!eVar.b.a()) { r rVar2 = new r(eVar.a.getFilesDir(), eVar.m, eVar.c); eVar.l = rVar2; if (rVar2.b == null) { synchronized (rVar2.e) { rVar2.b = new Handler(Looper.getMainLooper()); } } rVar2.b.post(new b.RunnableC0109b(null)); } if (!eVar.o) { eVar.b.a(str, eVar.s); } m mVar = eVar.z; if (mVar != null) { mVar.b(); } } } public final void a(InneractiveVideoError inneractiveVideoError, JSONObject jSONObject, boolean z) { JSONObject jSONObject2; InneractiveErrorCode inneractiveErrorCode; com.fyber.inneractive.sdk.network.q qVar; com.fyber.inneractive.sdk.model.vast.b bVar; com.fyber.inneractive.sdk.network.q qVar2; if (jSONObject != null || inneractiveVideoError == null) { jSONObject2 = jSONObject; } else { jSONObject2 = new JSONObject(); ((e) this.f).b(inneractiveVideoError, jSONObject2); } com.fyber.inneractive.sdk.flow.g gVar = com.fyber.inneractive.sdk.flow.g.UNSPECIFIED; if (inneractiveVideoError != null) { InneractiveVideoError.Error playerError = inneractiveVideoError.getPlayerError(); int i = a.a[playerError.ordinal()]; if (i == 1) { qVar2 = com.fyber.inneractive.sdk.network.q.VAST_ERROR_NO_MEDIA_FILES; } else if (i == 2) { qVar2 = com.fyber.inneractive.sdk.network.q.VAST_ERROR_FAILED_PLAYING_MEDIA_FILE; } else if (i == 3) { qVar2 = com.fyber.inneractive.sdk.network.q.VAST_ERROR_FAILED_PLAYING_ALL_MEDIA_FILES; } else if (i == 4) { qVar2 = com.fyber.inneractive.sdk.network.q.VAST_ERROR_PRE_BUFFER_TIMEOUT; } else if (i != 5) { IAlog.a("IAReportError, Does not know player error " + playerError.getErrorString(), new Object[0]); qVar2 = com.fyber.inneractive.sdk.network.q.VAST_UNKNOWN_PLAYER_ERROR; } else { qVar2 = com.fyber.inneractive.sdk.network.q.VAST_ERROR_BUFFER_TIMEOUT; } s.a aVar = new s.a(qVar2, this.b, this.c, this.h.c()); if (jSONObject2 != null) { try { aVar.f.put(new JSONObject(jSONObject2.toString())); } catch (Exception unused) { } } aVar.a((String) null); } if (InneractiveErrorCode.NON_SECURE_CONTENT_DETECTED == null) { new s.a(com.fyber.inneractive.sdk.network.q.VPAID_ERROR_UNSECURE_CONTENT, this.b, this.c, this.h.c()).a((String) null); } if (inneractiveVideoError != null) { IAlog.a("got onMediaPlayerLoadError with: " + inneractiveVideoError.getPlayerError(), new Object[0]); if (z) { inneractiveErrorCode = InneractiveErrorCode.LOAD_TIMEOUT; gVar = com.fyber.inneractive.sdk.flow.g.VIDEO_AD_LOAD_TIMEOUT; } else { inneractiveErrorCode = null; } IAlog.a("got onMediaPlayerLoadError with: " + inneractiveVideoError.description(), new Object[0]); if (inneractiveVideoError.getPlayerError().isFatal()) { inneractiveErrorCode = InneractiveErrorCode.SERVER_INVALID_RESPONSE; gVar = com.fyber.inneractive.sdk.flow.g.VIDEO_FATAL_ERROR; } if (inneractiveErrorCode == null) { inneractiveErrorCode = InneractiveErrorCode.SERVER_INVALID_RESPONSE; gVar = com.fyber.inneractive.sdk.flow.g.VIDEO_ERROR_UNSPECIFIED; } } else { inneractiveErrorCode = null; } if (z) { return; } this.e = null; com.fyber.inneractive.sdk.response.g gVar2 = this.c; if (gVar2 != null && (bVar = gVar2.L) != null) { this.e = bVar.d.poll(); } if (this.e != null) { if (this.g) { return; } try { this.f = this.a.a(); } catch (Throwable th) { b bVar2 = this.d; InneractiveInfrastructureError inneractiveInfrastructureError = new InneractiveInfrastructureError(InneractiveErrorCode.SDK_INTERNAL_ERROR, com.fyber.inneractive.sdk.flow.g.COULD_NOT_CREATE_FLOW_MANAGER, th); o oVar = (o) bVar2; oVar.b(inneractiveInfrastructureError); oVar.a(inneractiveInfrastructureError); } c(); return; } InneractiveVideoError.Error playerError2 = new InneractiveVideoError(InneractiveVideoError.Error.ERROR_FAILED_PLAYING_ALL_MEDIA_FILES).getPlayerError(); int i2 = a.a[playerError2.ordinal()]; if (i2 == 1) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_NO_MEDIA_FILES; } else if (i2 == 2) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_FAILED_PLAYING_MEDIA_FILE; } else if (i2 == 3) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_FAILED_PLAYING_ALL_MEDIA_FILES; } else if (i2 == 4) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_PRE_BUFFER_TIMEOUT; } else if (i2 != 5) { IAlog.a("IAReportError, Does not know player error " + playerError2.getErrorString(), new Object[0]); qVar = com.fyber.inneractive.sdk.network.q.VAST_UNKNOWN_PLAYER_ERROR; } else { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_BUFFER_TIMEOUT; } new s.a(qVar, this.b, this.c, this.h.c()).a((String) null); b bVar3 = this.d; if (bVar3 != null) { if (inneractiveVideoError != null) { InneractiveInfrastructureError inneractiveInfrastructureError2 = new InneractiveInfrastructureError(inneractiveErrorCode, gVar, inneractiveVideoError.getCause()); o oVar2 = (o) bVar3; oVar2.b(inneractiveInfrastructureError2); oVar2.a(inneractiveInfrastructureError2); } else { InneractiveInfrastructureError inneractiveInfrastructureError3 = new InneractiveInfrastructureError(inneractiveErrorCode, com.fyber.inneractive.sdk.flow.g.VIDEO_ERROR_NULL); o oVar3 = (o) bVar3; oVar3.b(inneractiveInfrastructureError3); oVar3.a(inneractiveInfrastructureError3); } a(); } } }