d.java 源代码
package com.bykv.vk.openvk.component.video.a.d;
import android.graphics.SurfaceTexture;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
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 com.bykv.vk.openvk.component.video.a.d.c;
import com.bykv.vk.openvk.component.video.api.a;
import com.bykv.vk.openvk.component.video.api.e.e;
import com.mbridge.msdk.thrid.okhttp.internal.http.StatusLine;
import com.x8zs.plugin.apache.http.HttpStatus;
import java.io.File;
import java.io.FileInputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class d implements c.a, c.b, c.InterfaceC0143c, c.d, c.e, c.f, c.g, com.bykv.vk.openvk.component.video.api.a, e.a {
private static boolean f8278v;
private static final SparseIntArray f8279x = new SparseIntArray();
private boolean F;
private boolean K;
private SurfaceTexture f8280a;
private SurfaceHolder f8281b;
private boolean f8287h;
private boolean f8288i;
private final Handler f8291l;
private boolean f8298s;
private ArrayList<Runnable> f8299t;
private int f8300u;
private boolean f8302y;
private int f8282c = 0;
private boolean f8283d = false;
private c f8284e = null;
private boolean f8285f = false;
private boolean f8286g = false;
private volatile int f8289j = 201;
private long f8290k = -1;
private boolean f8292m = false;
private long f8293n = 0;
private long f8294o = Long.MIN_VALUE;
private long f8295p = 0;
private long f8296q = 0;
private long f8297r = 0;
private String f8301w = "0";
private final List<WeakReference<a.InterfaceC0145a>> f8303z = Collections.synchronizedList(new ArrayList());
private com.bykv.vk.openvk.component.video.api.b.c A = null;
private int B = 0;
private volatile int C = 200;
private Runnable D = new Runnable() {
@Override
public void run() {
int intValue;
long q6 = d.this.q();
if (q6 > 0 && Build.VERSION.SDK_INT >= 23 && d.this.k() && d.this.f8294o != Long.MIN_VALUE) {
if (d.this.f8294o == q6) {
if (!d.this.f8292m && d.this.f8295p >= 400) {
d.this.b(701, 800);
d.this.f8292m = true;
}
d.this.f8295p += d.this.C;
} else {
if (d.this.f8292m) {
d.this.f8293n += d.this.f8295p;
d.this.b(702, 800);
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "handleMsg: bufferingDuration =", Long.valueOf(d.this.f8293n), " bufferCount =", Integer.valueOf(d.this.f8282c));
}
d.this.f8295p = 0L;
d.this.f8292m = false;
}
}
d.this.f8294o = q6;
long o6 = d.this.o();
if (o6 > 0 && d.this.B != (intValue = Float.valueOf((((float) q6) * 100.0f) / ((float) o6)).intValue())) {
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "run: lastPercent = ", Integer.valueOf(d.this.B), " percent = ", Integer.valueOf(intValue));
d dVar = d.this;
dVar.a(q6, dVar.o());
d.this.B = intValue;
}
if (!d.this.g()) {
d.this.f8291l.postDelayed(this, d.this.C);
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "System interval = ", Integer.valueOf(d.this.C));
} else {
d dVar2 = d.this;
dVar2.a(dVar2.o(), d.this.o());
}
}
};
private a E = new a();
private final Object G = new Object();
private StringBuilder H = null;
private long I = 0;
private long J = 0;
class a implements Runnable {
private long f8322b;
a() {
}
public void a(long j6) {
this.f8322b = j6;
}
@Override
public void run() {
if (d.this.f8284e != null) {
try {
d.this.f8290k = Math.max(this.f8322b, d.this.f8284e.i());
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] MediaPlayerProxy#start error: getCurrentPosition :" + th.toString());
}
}
d.this.f8291l.sendEmptyMessageDelayed(100, 0L);
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] MediaPlayerProxy#start not first play ! sendMsg --> OP_START , video start to play !");
}
}
public d() {
this.f8300u = 0;
this.K = false;
this.f8300u = 0;
HandlerThread handlerThread = new HandlerThread("tt_pangle_thread_SSMediaPlayerWrapper", -1);
handlerThread.start();
com.bykv.vk.openvk.component.video.api.e.e eVar = new com.bykv.vk.openvk.component.video.api.e.e(handlerThread.getLooper(), this);
this.f8291l = eVar;
this.K = true;
eVar.post(new Runnable() {
@Override
public void run() {
d.this.s();
}
});
}
private void r() {
this.f8293n = 0L;
this.f8282c = 0;
this.f8295p = 0L;
this.f8292m = false;
this.f8294o = Long.MIN_VALUE;
}
public void s() {
if (this.f8284e == null) {
b bVar = new b();
this.f8284e = bVar;
this.f8301w = "0";
bVar.a((c.e) this);
this.f8284e.a((c.b) this);
this.f8284e.a((c.InterfaceC0143c) this);
this.f8284e.a((c.a) this);
this.f8284e.a((c.f) this);
this.f8284e.a((c.d) this);
this.f8284e.a((c.g) this);
try {
this.f8284e.b(this.f8285f);
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setLooping error: ", th);
}
this.f8286g = false;
}
}
private void t() {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] MediaPlayerProxy#start first play prepare invoke !");
b(new Runnable() {
@Override
public void run() {
if (d.this.f8291l != null) {
d.this.f8291l.sendEmptyMessage(104);
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] MediaPlayerProxy#start first play prepare invoke ! sendMsg --> OP_PREPARE_ASYNC");
}
}
});
}
private void u() {
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "releaseMediaPlayer: ");
c cVar = this.f8284e;
if (cVar == null) {
return;
}
try {
cVar.l();
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "releaseMediaplayer error1: ", th);
}
this.f8284e.a((c.b) null);
this.f8284e.a((c.g) null);
this.f8284e.a((c.a) null);
this.f8284e.a((c.d) null);
this.f8284e.a((c.InterfaceC0143c) null);
this.f8284e.a((c.e) null);
this.f8284e.a((c.f) null);
try {
this.f8284e.k();
} catch (Throwable th2) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "releaseMediaplayer error2: ", th2);
}
}
private void v() {
Handler handler = this.f8291l;
if (handler != null && handler.getLooper() != null) {
this.f8291l.post(new Runnable() {
@Override
public void run() {
if (d.this.f8291l.getLooper() != null) {
try {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "onDestory............");
d.this.f8291l.getLooper().quit();
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "onDestroy error: ", th);
}
}
}
});
}
}
private void w() {
SparseIntArray sparseIntArray = f8279x;
Integer valueOf = Integer.valueOf(sparseIntArray.get(this.f8300u));
if (valueOf == null) {
sparseIntArray.put(this.f8300u, 1);
} else {
sparseIntArray.put(this.f8300u, Integer.valueOf(valueOf.intValue() + 1).intValue());
}
}
private void x() {
if (this.f8287h) {
return;
}
this.f8287h = true;
Iterator it = new ArrayList(this.f8299t).iterator();
while (it.hasNext()) {
((Runnable) it.next()).run();
}
this.f8299t.clear();
this.f8287h = false;
}
private void y() {
ArrayList<Runnable> arrayList = this.f8299t;
if (arrayList != null && !arrayList.isEmpty()) {
x();
}
}
private void z() {
ArrayList<Runnable> arrayList = this.f8299t;
if (arrayList != null && !arrayList.isEmpty()) {
this.f8299t.clear();
}
}
@Override
public long n() {
if (Build.VERSION.SDK_INT >= 23) {
if (this.f8292m) {
long j6 = this.f8295p;
if (j6 > 0) {
return this.f8293n + j6;
}
}
return this.f8293n;
}
return this.J;
}
@Override
public long o() {
long j6 = this.f8296q;
if (j6 != 0) {
return j6;
}
if (this.f8289j == 206 || this.f8289j == 207) {
try {
this.f8296q = this.f8284e.j();
} catch (Throwable unused) {
}
}
return this.f8296q;
}
public boolean p() {
if (this.f8289j == 205) {
return true;
}
return false;
}
public long q() {
if (this.f8289j == 206 || this.f8289j == 207) {
try {
return this.f8284e.i();
} catch (Throwable unused) {
return 0L;
}
}
return 0L;
}
@Override
public SurfaceHolder e() {
return this.f8281b;
}
@Override
public SurfaceTexture f() {
return this.f8280a;
}
@Override
public boolean g() {
return this.f8289j == 209;
}
@Override
public boolean h() {
return p() || k() || l();
}
@Override
public int i() {
c cVar = this.f8284e;
if (cVar != null) {
return cVar.m();
}
return 0;
}
@Override
public int j() {
c cVar = this.f8284e;
if (cVar != null) {
return cVar.n();
}
return 0;
}
@Override
public boolean k() {
return (this.f8289j == 206 || this.f8291l.hasMessages(100)) && !this.F;
}
@Override
public boolean l() {
return (this.f8289j == 207 || this.F) && !this.f8291l.hasMessages(100);
}
@Override
public boolean m() {
return this.f8289j == 203;
}
@Override
public void c() {
b(new Runnable() {
@Override
public void run() {
if (d.this.f8291l != null) {
d.this.f8291l.sendEmptyMessage(105);
}
}
});
}
@Override
public void d() {
this.f8289j = HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION;
z();
if (this.f8291l != null) {
try {
b("release");
this.f8291l.removeCallbacksAndMessages(null);
if (this.f8284e != null) {
this.f8288i = true;
this.f8291l.sendEmptyMessage(103);
}
} finally {
try {
} finally {
}
}
}
}
@Override
public void c(c cVar) {
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a((com.bykv.vk.openvk.component.video.api.a) this, true);
}
}
}
@Override
public void b(boolean z6) {
this.f8302y = z6;
}
@Override
public void b() {
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "pause: ");
this.f8291l.removeMessages(100);
this.F = true;
this.f8291l.sendEmptyMessage(101);
}
public void a(long j6, long j7) {
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a(this, j6, j7);
}
}
}
@Override
public void a(boolean z6, long j6, boolean z7) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] MediaPlayerProxy#start firstSeekToPosition=" + j6 + ",firstPlay :" + z6 + ",isPauseOtherMusicVolume=" + z7);
if (this.f8284e == null) {
return;
}
this.F = false;
if (z6) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] first start , SSMediaPlayer start method !");
this.f8290k = j6;
t();
} else {
this.E.a(j6);
if (this.f8302y) {
b(this.E);
} else {
a(this.E);
}
}
this.f8291l.postDelayed(this.D, this.C);
}
@Override
public boolean b(c cVar, int i6, int i7) {
com.bykv.vk.openvk.component.video.api.e.d.c("SSMediaPlayeWrapper", "what,extra:" + i6 + "," + i7);
if (this.f8284e != cVar) {
return false;
}
if (i7 == -1004) {
com.bykv.vk.openvk.component.video.api.b.a aVar = new com.bykv.vk.openvk.component.video.api.b.a(i6, i7);
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a(this, aVar);
}
}
}
b(i6, i7);
return false;
}
public void b(int i6, int i7) {
if (i6 == 701) {
this.I = SystemClock.elapsedRealtime();
this.f8282c++;
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a(this, Integer.MAX_VALUE, 0, 0);
}
}
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "bufferCount = ", Integer.valueOf(this.f8282c));
return;
}
if (i6 == 702) {
if (this.I > 0) {
this.J += SystemClock.elapsedRealtime() - this.I;
this.I = 0L;
}
for (WeakReference<a.InterfaceC0145a> weakReference2 : this.f8303z) {
if (weakReference2 != null && weakReference2.get() != null) {
weakReference2.get().a((com.bykv.vk.openvk.component.video.api.a) this, Integer.MAX_VALUE);
}
}
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "bufferCount = ", Integer.valueOf(this.f8282c), " mBufferTotalTime = ", Long.valueOf(this.J));
return;
}
if (this.K && i6 == 3) {
long elapsedRealtime = SystemClock.elapsedRealtime() - this.f8297r;
this.f8283d = true;
for (WeakReference<a.InterfaceC0145a> weakReference3 : this.f8303z) {
if (weakReference3 != null && weakReference3.get() != null) {
weakReference3.get().a(this, elapsedRealtime);
}
}
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "onRenderStart");
}
}
@Override
public void a() {
Handler handler = this.f8291l;
if (handler != null) {
handler.post(new Runnable() {
@Override
public void run() {
if (d.this.l() && d.this.f8284e != null) {
try {
d.this.f8284e.e();
for (WeakReference weakReference : d.this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
((a.InterfaceC0145a) weakReference.get()).e(d.this);
}
}
d.this.f8289j = HttpStatus.SC_PARTIAL_CONTENT;
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "play: catch exception ", th.getMessage());
}
}
}
});
}
}
@Override
public void a(final long j6) {
if (this.f8289j == 207 || this.f8289j == 206 || this.f8289j == 209) {
b(new Runnable() {
@Override
public void run() {
if (d.this.f8291l != null) {
d.this.f8291l.obtainMessage(106, Long.valueOf(j6)).sendToTarget();
}
}
});
}
}
@Override
public void a(final SurfaceTexture surfaceTexture) {
this.f8280a = surfaceTexture;
b(true);
b(new Runnable() {
@Override
public void run() {
d.this.s();
if (d.this.f8291l != null) {
d.this.f8291l.obtainMessage(111, surfaceTexture).sendToTarget();
}
}
});
}
@Override
public void a(final SurfaceHolder surfaceHolder) {
this.f8281b = surfaceHolder;
b(true);
b(new Runnable() {
@Override
public void run() {
d.this.s();
if (d.this.f8291l != null) {
d.this.f8291l.obtainMessage(110, surfaceHolder).sendToTarget();
}
}
});
}
@Override
public void a(final com.bykv.vk.openvk.component.video.api.b.c cVar) {
this.A = cVar;
b(new Runnable() {
@Override
public void run() {
d.this.s();
if (d.this.f8291l != null) {
d.this.f8291l.obtainMessage(107, cVar).sendToTarget();
}
}
});
}
@Override
public void a(Message message) {
int i6 = message.what;
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] execute , mCurrentState = " + this.f8289j + " handlerMsg=" + i6);
c cVar = this.f8284e;
boolean z6 = false;
if (cVar != null) {
switch (message.what) {
case 100:
if (this.f8289j == 205 || this.f8289j == 207 || this.f8289j == 209) {
try {
this.f8284e.e();
this.f8297r = SystemClock.elapsedRealtime();
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] OP_START execute , mMediaPlayer real start !");
this.f8289j = HttpStatus.SC_PARTIAL_CONTENT;
long j6 = this.f8290k;
if (j6 > 0) {
this.f8284e.a(j6);
this.f8290k = -1L;
}
com.bykv.vk.openvk.component.video.api.b.c cVar2 = this.A;
if (cVar2 != null) {
a(cVar2.f());
break;
}
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_START error: ", th);
break;
}
}
z6 = true;
break;
case 101:
if (this.f8292m) {
this.f8293n += this.f8295p;
}
this.f8292m = false;
this.f8295p = 0L;
this.f8294o = Long.MIN_VALUE;
if (this.f8289j == 206 || this.f8289j == 207 || this.f8289j == 209) {
try {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] OP_PAUSE execute , mMediaPlayer OP_PAUSE !");
this.f8284e.g();
this.f8289j = HttpStatus.SC_MULTI_STATUS;
this.F = false;
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().d(this);
}
}
break;
} catch (Throwable th2) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_PAUSE error: ", th2);
break;
}
}
z6 = true;
break;
case 102:
try {
cVar.l();
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] OP_RELEASE execute , releaseMediaplayer !");
this.f8289j = 201;
break;
} catch (Throwable th3) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_RESET error: ", th3);
break;
}
case 103:
try {
u();
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] OP_RELEASE execute , releaseMediaplayer !");
} catch (Throwable th4) {
com.bykv.vk.openvk.component.video.api.e.d.c("SSMediaPlayeWrapper", "OP_RELEASE error: ", th4);
}
this.f8288i = false;
for (WeakReference<a.InterfaceC0145a> weakReference2 : this.f8303z) {
if (weakReference2 != null && weakReference2.get() != null) {
weakReference2.get().c(this);
}
}
this.f8289j = HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION;
break;
case 104:
if (this.f8289j == 202 || this.f8289j == 208) {
try {
this.f8284e.h();
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "[video] OP_PREPARE_ASYNC execute , mMediaPlayer real prepareAsync !");
break;
} catch (Throwable th5) {
com.bykv.vk.openvk.component.video.api.e.d.c("SSMediaPlayeWrapper", "OP_PREPARE_ASYNC error: ", th5);
break;
}
}
z6 = true;
break;
case 105:
if (this.f8289j == 205 || this.f8289j == 206 || this.f8289j == 208 || this.f8289j == 207 || this.f8289j == 209) {
try {
this.f8284e.f();
this.f8289j = 208;
break;
} catch (Throwable th6) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_STOP error: ", th6);
break;
}
}
z6 = true;
break;
case 106:
if (this.f8289j == 206 || this.f8289j == 207 || this.f8289j == 209) {
try {
this.f8284e.a(((Long) message.obj).longValue());
break;
} catch (Throwable th7) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_SEEKTO error: ", th7);
break;
}
}
z6 = true;
break;
case 107:
r();
if (this.f8289j == 201 || this.f8289j == 203) {
try {
com.bykv.vk.openvk.component.video.api.b.c cVar3 = (com.bykv.vk.openvk.component.video.api.b.c) message.obj;
if (TextUtils.isEmpty(cVar3.a())) {
cVar3.a(com.bykv.vk.openvk.component.video.api.b.b());
}
File file = new File(cVar3.a(), cVar3.j());
if (file.exists()) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setDataSource: try paly local:" + file.getAbsolutePath());
if (com.bykv.vk.openvk.component.video.api.b.d()) {
a(file.getAbsolutePath());
} else {
this.f8284e.a(file.getAbsolutePath());
}
} else {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setDataSource: paly net:" + cVar3.i());
if (cVar3.f8352b == 1 && Build.VERSION.SDK_INT < 23) {
this.f8284e.a(cVar3.i());
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setDataSource: 直接设置 url" + cVar3.i());
} else if (Build.VERSION.SDK_INT >= 23) {
this.f8284e.a(cVar3);
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setDataSource: 使用MediaDataSource接口 url" + cVar3.i());
} else {
String b6 = com.bykv.vk.openvk.component.video.a.b.f.a.a().b(cVar3);
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setDataSource: 本地代理模式 local url = ", b6);
if (b6 != null && com.bykv.vk.openvk.component.video.api.b.d() && b6.startsWith("file")) {
a(Uri.parse(b6).getPath());
} else {
this.f8284e.a(b6);
}
}
}
this.f8289j = HttpStatus.SC_ACCEPTED;
break;
} catch (Throwable th8) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_SET_DATASOURCE error: ", th8);
break;
}
}
z6 = true;
break;
case 110:
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "resumeVideo: OP_SET_DISPLAY ");
try {
this.f8284e.a((SurfaceHolder) message.obj);
if (this.f8300u == 2) {
this.f8284e.a(com.bykv.vk.openvk.component.video.api.b.a(), 10);
}
this.f8284e.a(true);
y();
break;
} catch (Throwable th9) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_SET_DISPLAY error: ", th9);
break;
}
case 111:
try {
cVar.a(new Surface((SurfaceTexture) message.obj));
this.f8284e.a(true);
this.f8284e.a(com.bykv.vk.openvk.component.video.api.b.a(), 10);
y();
break;
} catch (Throwable th10) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OP_SET_SURFACE error: ", th10);
break;
}
}
}
if (z6) {
this.f8289j = 200;
if (this.f8286g) {
return;
}
com.bykv.vk.openvk.component.video.api.b.a aVar = new com.bykv.vk.openvk.component.video.api.b.a(StatusLine.HTTP_PERM_REDIRECT, i6);
for (WeakReference<a.InterfaceC0145a> weakReference3 : this.f8303z) {
if (weakReference3 != null && weakReference3.get() != null) {
weakReference3.get().a(this, aVar);
}
}
this.f8286g = true;
}
}
@Override
public void b(c cVar) {
this.f8289j = HttpStatus.SC_RESET_CONTENT;
if (this.F) {
this.f8291l.post(new Runnable() {
@Override
public void run() {
try {
d.this.f8284e.g();
d.this.f8289j = HttpStatus.SC_MULTI_STATUS;
d.this.F = false;
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "onPrepared error: ", th);
}
}
});
} else {
Handler handler = this.f8291l;
handler.sendMessage(handler.obtainMessage(100, -1, -1));
}
f8279x.delete(this.f8300u);
if (!this.K && !this.f8298s) {
long elapsedRealtime = SystemClock.elapsedRealtime() - this.f8297r;
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a(this, elapsedRealtime);
}
}
this.f8283d = true;
this.f8298s = true;
}
for (WeakReference<a.InterfaceC0145a> weakReference2 : this.f8303z) {
if (weakReference2 != null && weakReference2.get() != null) {
weakReference2.get().b(this);
}
}
}
private void b(Runnable runnable) {
if (runnable == null) {
return;
}
if (!this.f8288i) {
runnable.run();
} else {
a(runnable);
}
}
private void b(String str) {
Handler handler = this.f8291l;
if (handler != null) {
handler.removeMessages(201);
}
synchronized (this.G) {
if (this.H != null) {
this.H = null;
}
}
}
private void a(String str) throws Throwable {
FileInputStream fileInputStream = new FileInputStream(str);
this.f8284e.a(fileInputStream.getFD());
fileInputStream.close();
}
@Override
public void a(c cVar, int i6) {
if (this.f8284e != cVar) {
return;
}
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().b(this, i6);
}
}
}
@Override
public void a(c cVar) {
this.f8289j = !this.f8285f ? 209 : HttpStatus.SC_PARTIAL_CONTENT;
f8279x.delete(this.f8300u);
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a(this);
}
}
b("completion");
}
@Override
public boolean a(c cVar, int i6, int i7) {
com.bykv.vk.openvk.component.video.api.e.d.c("SSMediaPlayeWrapper", "what=" + i6 + "extra=" + i7);
w();
this.f8289j = 200;
Handler handler = this.f8291l;
if (handler != null) {
handler.removeCallbacks(this.D);
}
if (a(i6, i7)) {
v();
}
if (!this.f8286g) {
com.bykv.vk.openvk.component.video.api.b.a aVar = new com.bykv.vk.openvk.component.video.api.b.a(StatusLine.HTTP_PERM_REDIRECT, i7);
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a(this, aVar);
}
}
this.f8286g = true;
return true;
}
com.bykv.vk.openvk.component.video.api.b.a aVar2 = new com.bykv.vk.openvk.component.video.api.b.a(i6, i7);
for (WeakReference<a.InterfaceC0145a> weakReference2 : this.f8303z) {
if (weakReference2 != null && weakReference2.get() != null) {
weakReference2.get().a(this, aVar2);
}
}
return true;
}
private boolean a(int i6, int i7) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "OnError - Error code: " + i6 + " Extra code: " + i7);
boolean z6 = i6 == -1010 || i6 == -1007 || i6 == -1004 || i6 == -110 || i6 == 100 || i6 == 200;
if (i7 == 1 || i7 == 700 || i7 == 800) {
return true;
}
return z6;
}
private void a(Runnable runnable) {
if (this.f8299t == null) {
this.f8299t = new ArrayList<>();
}
this.f8299t.add(runnable);
}
@Override
public void a(final boolean z6) {
com.bykv.vk.openvk.component.video.api.b.c().post(new Runnable() {
@Override
public void run() {
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "run:before setQuietPlay ", Boolean.valueOf(z6));
if (!d.this.f8288i && d.this.f8289j != 203 && d.this.f8284e != null) {
try {
com.bykv.vk.openvk.component.video.api.e.d.b("SSMediaPlayeWrapper", "run:exec setQuietPlay ", Boolean.valueOf(z6));
d.this.f8284e.c(z6);
} catch (Throwable th) {
com.bykv.vk.openvk.component.video.api.e.d.a("SSMediaPlayeWrapper", "setQuietPlay error: ", th);
}
}
}
});
}
@Override
public void a(c cVar, int i6, int i7, int i8, int i9) {
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() != null) {
weakReference.get().a((com.bykv.vk.openvk.component.video.api.a) this, i6, i7);
}
}
}
@Override
public void a(a.InterfaceC0145a interfaceC0145a) {
if (interfaceC0145a == null) {
return;
}
for (WeakReference<a.InterfaceC0145a> weakReference : this.f8303z) {
if (weakReference != null && weakReference.get() == interfaceC0145a) {
return;
}
}
this.f8303z.add(new WeakReference<>(interfaceC0145a));
}
}