MD5 校验值:0dedfe548c7636ed7f4304e53560273f
Jzvd.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package cn.jzvd; import android.content.Context; import android.media.AudioManager; import android.provider.Settings; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; import cn.jzvd.Jzvd; import java.lang.reflect.InvocationTargetException; import java.util.LinkedList; import java.util.Timer; import java.util.TimerTask; public abstract class Jzvd extends FrameLayout implements View.OnClickListener, SeekBar.OnSeekBarChangeListener, View.OnTouchListener { public static Jzvd f2338a; public static LinkedList<ViewGroup> f2339b = new LinkedList<>(); public static boolean f2340c = true; public static int f2341d = 6; public static int f2342e = 1; public static boolean f2343f = false; public static boolean f2344g = false; public static int h = 0; public static long i = 0; public static int j = 0; public static AudioManager.OnAudioFocusChangeListener k = new w(); public TextView A; public TextView B; public ViewGroup C; public ViewGroup D; public ViewGroup E; public JZTextureView F; protected Timer G; protected int H; protected int I; protected AudioManager J; protected a K; protected boolean L; protected float M; protected float N; protected boolean O; protected boolean P; protected boolean Q; protected long R; protected int S; protected float T; protected long U; public boolean V; public int l; public int m; public t n; public int o; public int p; public Class q; public u r; public int s; public int t; protected long u; public int v; public long w; public ImageView x; public SeekBar y; public ImageView z; public class a extends TimerTask { public a() { } public void a() { long currentPositionWhenPlaying = Jzvd.this.getCurrentPositionWhenPlaying(); long duration = Jzvd.this.getDuration(); Jzvd.this.a((int) ((100 * currentPositionWhenPlaying) / (duration == 0 ? 1L : duration)), currentPositionWhenPlaying, duration); } @Override public void run() { int i = Jzvd.this.l; if (i == 4 || i == 5) { Jzvd.this.post(new Runnable() { @Override public final void run() { Jzvd.a.this.a(); } }); } } } public Jzvd(Context context) { super(context); this.l = -1; this.m = -1; this.o = 0; this.p = 0; this.s = -1; this.t = 0; this.u = 0L; this.v = -1; this.w = 0L; this.V = false; a(context); } public static void h() { Jzvd jzvd = f2338a; if (jzvd != null) { int i2 = jzvd.l; if (i2 != 6 && i2 != 0 && i2 != 1 && i2 != 7) { j = i2; jzvd.r(); f2338a.r.pause(); return; } u(); } } public static void i() { Jzvd jzvd = f2338a; if (jzvd == null || jzvd.l != 5) { return; } if (j == 5) { jzvd.r(); f2338a.r.pause(); } else { jzvd.s(); f2338a.r.start(); } j = 0; } public static void setCurrentJzvd(Jzvd jzvd) { Jzvd jzvd2 = f2338a; if (jzvd2 != null) { jzvd2.v(); } f2338a = jzvd; } public static void setTextureViewRotation(int i2) { JZTextureView jZTextureView; Jzvd jzvd = f2338a; if (jzvd == null || (jZTextureView = jzvd.F) == null) { return; } jZTextureView.setRotation(i2); } public static void setVideoImageDisplayType(int i2) { JZTextureView jZTextureView; h = i2; Jzvd jzvd = f2338a; if (jzvd == null || (jZTextureView = jzvd.F) == null) { return; } jZTextureView.requestLayout(); } public static void u() { Log.d("JZVD", "releaseAllVideos"); Jzvd jzvd = f2338a; if (jzvd != null) { jzvd.v(); f2338a = null; } } public void A() { } public void B() { Log.i("JZVD", "startProgressTimer: [" + hashCode() + "] "); c(); this.G = new Timer(); this.K = new a(); this.G.schedule(this.K, 0L, 300L); } public void C() { Log.d("JZVD", "startVideo [" + hashCode() + "] "); setCurrentJzvd(this); try { this.r = (u) this.q.getConstructor(Jzvd.class).newInstance(this); } catch (IllegalAccessException e2) { e2.printStackTrace(); } catch (InstantiationException e3) { e3.printStackTrace(); } catch (NoSuchMethodException e4) { e4.printStackTrace(); } catch (InvocationTargetException e5) { e5.printStackTrace(); } a(); this.J = (AudioManager) getApplicationContext().getSystemService("audio"); this.J.requestAudioFocus(k, 3, 2); v.f(getContext()).getWindow().addFlags(128); t(); } public void a(float f2, int i2) { } public void a(float f2, String str, long j2, String str2, long j3) { } public void a(int i2) { } public void a(Context context) { View.inflate(context, getLayoutId(), this); this.x = (ImageView) findViewById(R$id.start); this.z = (ImageView) findViewById(R$id.fullscreen); this.y = (SeekBar) findViewById(R$id.bottom_seek_progress); this.A = (TextView) findViewById(R$id.current); this.B = (TextView) findViewById(R$id.total); this.E = (ViewGroup) findViewById(R$id.layout_bottom); this.C = (ViewGroup) findViewById(R$id.surface_container); this.D = (ViewGroup) findViewById(R$id.layout_top); this.x.setOnClickListener(this); this.z.setOnClickListener(this); this.y.setOnSeekBarChangeListener(this); this.E.setOnClickListener(this); this.C.setOnClickListener(this); this.C.setOnTouchListener(this); this.H = getContext().getResources().getDisplayMetrics().widthPixels; this.I = getContext().getResources().getDisplayMetrics().heightPixels; this.l = -1; } public void b(int i2, int i3) { Log.d("JZVD", "onInfo what - " + i2 + " extra - " + i3); if (i2 == 3) { int i4 = this.l; if (i4 == 3 || i4 == 2) { s(); } } } public void c(int i2, int i3) { Log.i("JZVD", "onVideoSizeChanged [" + hashCode() + "] "); JZTextureView jZTextureView = this.F; if (jZTextureView != null) { int i4 = this.t; if (i4 != 0) { jZTextureView.setRotation(i4); } this.F.a(i2, i3); } } public void d() { v.g(getContext()); v.a(getContext(), f2342e); v.h(getContext()); ((ViewGroup) v.f(getContext()).getWindow().getDecorView()).removeView(this); u uVar = this.r; if (uVar != null) { uVar.release(); } f2338a = null; } public void e() { } public void f() { } public void g() { } public Context getApplicationContext() { Context applicationContext; Context context = getContext(); return (context == null || (applicationContext = context.getApplicationContext()) == null) ? context : applicationContext; } public long getCurrentPositionWhenPlaying() { int i2 = this.l; if (i2 != 4 && i2 != 5) { return 0L; } try { return this.r.getCurrentPosition(); } catch (IllegalStateException e2) { e2.printStackTrace(); return 0L; } } public long getDuration() { try { return this.r.getDuration(); } catch (IllegalStateException e2) { e2.printStackTrace(); return 0L; } } public abstract int getLayoutId(); public void j() { ViewGroup viewGroup = (ViewGroup) getParent(); viewGroup.removeView(this); a(viewGroup); f2339b.add(viewGroup); ((ViewGroup) v.f(getContext()).getWindow().getDecorView()).addView(this, new FrameLayout.LayoutParams(-1, -1)); x(); v.c(getContext()); v.a(getContext(), f2341d); v.d(getContext()); } public void k() { this.u = System.currentTimeMillis(); ((ViewGroup) v.f(getContext()).getWindow().getDecorView()).removeView(this); f2339b.getLast().removeAllViews(); f2339b.getLast().addView(this, new FrameLayout.LayoutParams(-1, -1)); f2339b.pop(); y(); v.g(getContext()); v.a(getContext(), f2342e); v.h(getContext()); } public void l() { Runtime.getRuntime().gc(); Log.i("JZVD", "onAutoCompletion [" + hashCode() + "] "); c(); e(); f(); g(); o(); this.r.release(); v.f(getContext()).getWindow().clearFlags(128); v.a(getContext(), this.n.c(), 0L); } public void m() { Log.i("JZVD", "onPrepared [" + hashCode() + "] "); this.l = 3; if (!this.V) { this.r.start(); this.V = false; } if (this.n.c().toString().toLowerCase().contains("mp3") || this.n.c().toString().toLowerCase().contains("wav")) { s(); } } public void n() { } public void o() { Log.i("JZVD", "onStateAutoComplete [" + hashCode() + "] "); this.l = 6; c(); this.y.setProgress(100); this.A.setText(this.B.getText()); } @Override public void onClick(View view) { int id = view.getId(); if (id == R$id.start) { Log.i("JZVD", "onClick start [" + hashCode() + "] "); t tVar = this.n; if (tVar != null && !tVar.f2379b.isEmpty() && this.n.c() != null) { int i2 = this.l; if (i2 == 0) { if (!this.n.c().toString().startsWith("file") && !this.n.c().toString().startsWith("/") && !v.e(getContext()) && !f2344g) { A(); return; } else { C(); return; } } if (i2 == 4) { Log.d("JZVD", "pauseVideo [" + hashCode() + "] "); this.r.pause(); r(); return; } if (i2 == 5) { this.r.start(); s(); return; } else { if (i2 == 6) { C(); return; } return; } } Toast.makeText(getContext(), getResources().getString(R$string.no_url), 0).show(); return; } if (id == R$id.fullscreen) { Log.i("JZVD", "onClick fullscreen [" + hashCode() + "] "); if (this.l == 6) { return; } if (this.m == 1) { b(); return; } Log.d("JZVD", "toFullscreenActivity [" + hashCode() + "] "); j(); } } @Override protected void onMeasure(int i2, int i3) { int i4 = this.m; if (i4 != 1 && i4 != 2) { if (this.o != 0 && this.p != 0) { int size = View.MeasureSpec.getSize(i2); int i5 = (int) ((size * this.p) / this.o); setMeasuredDimension(size, i5); getChildAt(0).measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(i5, 1073741824)); return; } super.onMeasure(i2, i3); return; } super.onMeasure(i2, i3); } @Override public void onProgressChanged(SeekBar seekBar, int i2, boolean z) { if (z) { this.A.setText(v.a((i2 * getDuration()) / 100)); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { Log.i("JZVD", "bottomProgress onStartTrackingTouch [" + hashCode() + "] "); c(); for (ViewParent parent = getParent(); parent != null; parent = parent.getParent()) { parent.requestDisallowInterceptTouchEvent(true); } } @Override public void onStopTrackingTouch(SeekBar seekBar) { Log.i("JZVD", "bottomProgress onStopTrackingTouch [" + hashCode() + "] "); B(); for (ViewParent parent = getParent(); parent != null; parent = parent.getParent()) { parent.requestDisallowInterceptTouchEvent(false); } int i2 = this.l; if (i2 == 4 || i2 == 5) { long progress = (seekBar.getProgress() * getDuration()) / 100; this.v = seekBar.getProgress(); this.r.seekTo(progress); Log.i("JZVD", "seekTo " + progress + " [" + hashCode() + "] "); } } @Override public boolean onTouch(View view, MotionEvent motionEvent) { float x = motionEvent.getX(); float y = motionEvent.getY(); if (view.getId() == R$id.surface_container) { int action = motionEvent.getAction(); if (action == 0) { Log.i("JZVD", "onTouch surfaceContainer actionDown [" + hashCode() + "] "); this.L = true; this.M = x; this.N = y; this.O = false; this.P = false; this.Q = false; } else if (action == 1) { Log.i("JZVD", "onTouch surfaceContainer actionUp [" + hashCode() + "] "); this.L = false; f(); g(); e(); if (this.P) { this.r.seekTo(this.U); long duration = getDuration(); long j2 = this.U * 100; if (duration == 0) { duration = 1; } this.y.setProgress((int) (j2 / duration)); } boolean z = this.O; B(); } else if (action == 2) { Log.i("JZVD", "onTouch surfaceContainer actionMove [" + hashCode() + "] "); float f2 = x - this.M; float f3 = y - this.N; float abs = Math.abs(f2); float abs2 = Math.abs(f3); if (this.m == 1 && !this.P && !this.O && !this.Q && (abs > 80.0f || abs2 > 80.0f)) { c(); if (abs >= 80.0f) { if (this.l != 7) { this.P = true; this.R = getCurrentPositionWhenPlaying(); } } else if (this.M < this.H * 0.5f) { this.Q = true; float f4 = v.b(getContext()).getAttributes().screenBrightness; if (f4 < 0.0f) { try { this.T = Settings.System.getInt(getContext().getContentResolver(), "screen_brightness"); Log.i("JZVD", "current system brightness: " + this.T); } catch (Settings.SettingNotFoundException e2) { e2.printStackTrace(); } } else { this.T = f4 * 255.0f; Log.i("JZVD", "current activity brightness: " + this.T); } } else { this.O = true; this.S = this.J.getStreamVolume(3); } } if (this.P) { long duration2 = getDuration(); this.U = (int) (((float) this.R) + ((((float) duration2) * f2) / this.H)); if (this.U > duration2) { this.U = duration2; } a(f2, v.a(this.U), this.U, v.a(duration2), duration2); } if (this.O) { f3 = -f3; this.J.setStreamVolume(3, this.S + ((int) (((this.J.getStreamMaxVolume(3) * f3) * 3.0f) / this.I)), 0); a(-f3, (int) (((this.S * 100) / r0) + (((f3 * 3.0f) * 100.0f) / this.I))); } if (this.Q) { float f5 = -f3; WindowManager.LayoutParams attributes = v.b(getContext()).getAttributes(); float f6 = this.T; float f7 = (int) (((f5 * 255.0f) * 3.0f) / this.I); if ((f6 + f7) / 255.0f >= 1.0f) { attributes.screenBrightness = 1.0f; } else if ((f6 + f7) / 255.0f <= 0.0f) { attributes.screenBrightness = 0.01f; } else { attributes.screenBrightness = (f6 + f7) / 255.0f; } v.b(getContext()).setAttributes(attributes); a((int) (((this.T * 100.0f) / 255.0f) + (((f5 * 3.0f) * 100.0f) / this.I))); } } } return false; } public void p() { Log.i("JZVD", "onStateError [" + hashCode() + "] "); this.l = 7; c(); } public void q() { Log.i("JZVD", "onStateNormal [" + hashCode() + "] "); this.l = 0; c(); u uVar = this.r; if (uVar != null) { uVar.release(); } } public void r() { Log.i("JZVD", "onStatePause [" + hashCode() + "] "); this.l = 5; B(); } public void s() { Log.i("JZVD", "onStatePlaying [" + hashCode() + "] "); if (this.l == 3) { long j2 = this.w; if (j2 != 0) { this.r.seekTo(j2); this.w = 0L; } else { long a2 = v.a(getContext(), this.n.c()); if (a2 != 0) { this.r.seekTo(a2); } } } this.l = 4; B(); } public void setBufferProgress(int i2) { if (i2 != 0) { this.y.setSecondaryProgress(i2); } } public void setMediaInterface(Class cls) { v(); this.q = cls; } public void setScreen(int i2) { if (i2 == 0) { y(); } else if (i2 == 1) { x(); } else { if (i2 != 2) { return; } z(); } } public void setState(int i2) { a(i2, 0, 0); } public void t() { Log.i("JZVD", "onStatePreparing [" + hashCode() + "] "); this.l = 1; w(); } public void v() { Log.i("JZVD", "reset [" + hashCode() + "] "); int i2 = this.l; if (i2 == 4 || i2 == 5) { v.a(getContext(), this.n.c(), getCurrentPositionWhenPlaying()); } c(); e(); f(); g(); q(); this.C.removeAllViews(); ((AudioManager) getApplicationContext().getSystemService("audio")).abandonAudioFocus(k); v.f(getContext()).getWindow().clearFlags(128); u uVar = this.r; if (uVar != null) { uVar.release(); } } public void w() { this.y.setProgress(0); this.y.setSecondaryProgress(0); this.A.setText(v.a(0L)); this.B.setText(v.a(0L)); } public void x() { this.m = 1; } public void y() { this.m = 0; } public void z() { this.m = 2; } public static boolean b() { Jzvd jzvd; Jzvd jzvd2; Log.i("JZVD", "backPress"); if (f2339b.size() != 0 && (jzvd2 = f2338a) != null) { jzvd2.k(); return true; } if (f2339b.size() != 0 || (jzvd = f2338a) == null || jzvd.m == 0) { return false; } jzvd.d(); return true; } public void c() { Timer timer = this.G; if (timer != null) { timer.cancel(); } a aVar = this.K; if (aVar != null) { aVar.cancel(); } } public Jzvd(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.l = -1; this.m = -1; this.o = 0; this.p = 0; this.s = -1; this.t = 0; this.u = 0L; this.v = -1; this.w = 0L; this.V = false; a(context); } public void a(String str, String str2, int i2, Class cls) { a(new t(str, str2), i2, cls); } public void a(t tVar, int i2, Class cls) { if (System.currentTimeMillis() - this.u < 200) { return; } this.n = tVar; this.m = i2; q(); this.q = cls; } public void a(int i2, int i3) { Log.e("JZVD", "onError " + i2 + " - " + i3 + " [" + hashCode() + "] "); if (i2 == 38 || i3 == -38 || i2 == -38 || i3 == 38 || i3 == -19) { return; } p(); this.r.release(); } public void a(int i2, int i3, int i4) { if (i2 == 0) { q(); return; } if (i2 == 1) { t(); return; } if (i2 == 2) { a(i3, i4); return; } if (i2 == 4) { s(); return; } if (i2 == 5) { r(); } else if (i2 == 6) { o(); } else { if (i2 != 7) { return; } p(); } } public void a(int i2, long j2) { this.l = 2; this.w = j2; this.n.f2378a = i2; this.r.setSurface(null); this.r.release(); this.r.prepare(); } public void a() { Log.d("JZVD", "addTextureView [" + hashCode() + "] "); JZTextureView jZTextureView = this.F; if (jZTextureView != null) { this.C.removeView(jZTextureView); } this.F = new JZTextureView(getContext().getApplicationContext()); this.F.setSurfaceTextureListener(this.r); this.C.addView(this.F, new FrameLayout.LayoutParams(-1, -1, 17)); } public void a(int i2, long j2, long j3) { if (!this.L) { int i3 = this.v; if (i3 != -1) { if (i3 > i2) { return; } else { this.v = -1; } } else if (i2 != 0) { this.y.setProgress(i2); } } if (j2 != 0) { this.A.setText(v.a(j2)); } this.B.setText(v.a(j3)); } public void a(ViewGroup viewGroup) { try { Jzvd jzvd = (Jzvd) getClass().getConstructor(Context.class).newInstance(getContext()); jzvd.setId(getId()); viewGroup.addView(jzvd); jzvd.a(this.n.a(), 0, this.q); } catch (IllegalAccessException e2) { e2.printStackTrace(); } catch (InstantiationException e3) { e3.printStackTrace(); } catch (NoSuchMethodException e4) { e4.printStackTrace(); } catch (InvocationTargetException e5) { e5.printStackTrace(); } } }