Jzvd.java 源代码


package cn.jzvd;

import android.content.Context;
import android.media.AudioManager;
import android.provider.Settings;
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.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import cn.jzvd.Jzvd;
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
import i.o;
import i.p;
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 f315m0;

    public static LinkedList<ViewGroup> f316n0 = new LinkedList<>();

    public static boolean f317o0 = true;

    public static int f318p0 = 6;

    public static int f319q0 = 1;

    public static boolean f320r0 = true;

    public static boolean f321s0 = false;

    public static int f322t0 = 0;

    public static long f323u0 = 0;

    public static int f324v0 = 0;

    public static int f325w0 = -1;

    public static float f326x0 = 1.0f;

    public static AudioManager.OnAudioFocusChangeListener f327y0 = new a();
    public long A;
    public ImageView B;
    public SeekBar C;
    public ImageView D;
    public TextView E;
    public TextView F;
    public ViewGroup G;
    public ViewGroup H;
    public ViewGroup I;
    public JZTextureView J;
    public boolean K;
    protected long L;
    protected long M;
    protected Timer N;
    protected int O;
    protected int P;
    protected AudioManager Q;
    protected b R;
    protected boolean S;
    protected float T;
    protected float U;
    protected boolean V;
    protected boolean W;

    protected boolean f328b0;

    protected long f329c0;

    protected int f330d0;

    protected float f331e0;

    protected long f332f0;

    protected Context f333g0;

    protected long f334h0;

    protected ViewGroup.LayoutParams f335i0;

    protected int f336j0;

    protected int f337k0;

    protected int f338l0;

    public int f339q;

    public int f340r;

    public i.a f341s;

    public int f342t;

    public int f343u;

    public Class f344v;

    public i.b f345w;

    public int f346x;

    public int f347y;

    public int f348z;

    class a implements AudioManager.OnAudioFocusChangeListener {
        a() {
        }

        @Override
        public void onAudioFocusChange(int i6) {
            if (i6 != -2) {
                if (i6 == -1) {
                    Jzvd.E();
                    Log.d("JZVD", "AUDIOFOCUS_LOSS [" + hashCode() + "]");
                    return;
                }
                return;
            }
            try {
                Jzvd jzvd = Jzvd.f315m0;
                if (jzvd != null && jzvd.f339q == 5) {
                    jzvd.B.performClick();
                }
            } catch (IllegalStateException e6) {
                e6.printStackTrace();
            }
            Log.d("JZVD", "AUDIOFOCUS_LOSS_TRANSIENT [" + hashCode() + "]");
        }
    }

    public class b extends TimerTask {
        public b() {
        }

        public void b() {
            long j6;
            long currentPositionWhenPlaying = Jzvd.this.getCurrentPositionWhenPlaying();
            long duration = Jzvd.this.getDuration();
            long j7 = 100 * currentPositionWhenPlaying;
            if (duration == 0) {
                j6 = 1;
            } else {
                j6 = duration;
            }
            Jzvd.this.t((int) (j7 / j6), currentPositionWhenPlaying, duration);
        }

        @Override
        public void run() {
            Jzvd jzvd = Jzvd.this;
            int i6 = jzvd.f339q;
            if (i6 == 5 || i6 == 6 || i6 == 3) {
                jzvd.post(new Runnable() {
                    @Override
                    public final void run() {
                        Jzvd.b.this.b();
                    }
                });
            }
        }
    }

    public Jzvd(Context context) {
        super(context);
        this.f339q = -1;
        this.f340r = -1;
        this.f342t = 0;
        this.f343u = 0;
        this.f346x = -1;
        this.f347y = 0;
        this.f348z = -1;
        this.A = 0L;
        this.K = false;
        this.L = 0L;
        this.M = 0L;
        o(context);
    }

    public static void E() {
        Log.d("JZVD", "releaseAllVideos");
        Jzvd jzvd = f315m0;
        if (jzvd != null) {
            jzvd.F();
            f315m0 = null;
        }
        f316n0.clear();
    }

    public static boolean b() {
        Jzvd jzvd;
        Jzvd jzvd2;
        Log.i("JZVD", "backPress");
        if (f316n0.size() != 0 && (jzvd2 = f315m0) != null) {
            jzvd2.n();
            return true;
        }
        if (f316n0.size() == 0 && (jzvd = f315m0) != null && jzvd.f340r != 0) {
            jzvd.e();
            return true;
        }
        return false;
    }

    public static void setCurrentJzvd(Jzvd jzvd) {
        Jzvd jzvd2 = f315m0;
        if (jzvd2 != null) {
            jzvd2.F();
        }
        f315m0 = jzvd;
    }

    public static void setTextureViewRotation(int i6) {
        JZTextureView jZTextureView;
        Jzvd jzvd = f315m0;
        if (jzvd != null && (jZTextureView = jzvd.J) != null) {
            jZTextureView.setRotation(i6);
        }
    }

    public static void setVideoImageDisplayType(int i6) {
        JZTextureView jZTextureView;
        f322t0 = i6;
        Jzvd jzvd = f315m0;
        if (jzvd != null && (jZTextureView = jzvd.J) != null) {
            jZTextureView.requestLayout();
        }
    }

    public void A() {
        Log.i("JZVD", "onStatePreparing  [" + hashCode() + "] ");
        this.f339q = 1;
        G();
    }

    public void B() {
        Log.i("JZVD", "onStatePreparingChangeUrl  [" + hashCode() + "] ");
        this.f339q = 2;
        E();
        S();
    }

    public void C() {
        Log.i("JZVD", "onStatePreparingPlaying  [" + hashCode() + "] ");
        this.f339q = 3;
    }

    public void D(int i6, int i7) {
        Log.i("JZVD", "onVideoSizeChanged  [" + hashCode() + "] ");
        JZTextureView jZTextureView = this.J;
        if (jZTextureView != null) {
            int i8 = this.f347y;
            if (i8 != 0) {
                jZTextureView.setRotation(i8);
            }
            this.J.a(i6, i7);
        }
    }

    public void F() {
        Log.i("JZVD", "reset  [" + hashCode() + "] ");
        int i6 = this.f339q;
        if (i6 == 5 || i6 == 6) {
            p.i(getContext(), this.f341s.c(), getCurrentPositionWhenPlaying());
        }
        c();
        i();
        j();
        k();
        x();
        this.G.removeAllViews();
        ((AudioManager) getApplicationContext().getSystemService(MimeTypes.BASE_TYPE_AUDIO)).abandonAudioFocus(f327y0);
        p.j(getContext()).getWindow().clearFlags(128);
        i.b bVar = this.f345w;
        if (bVar != null) {
            bVar.d();
        }
    }

    public void G() {
        this.f334h0 = 0L;
        this.C.setProgress(0);
        this.C.setSecondaryProgress(0);
        this.E.setText(p.n(0L));
        this.F.setText(p.n(0L));
    }

    public void H() {
        this.f340r = 1;
    }

    public void I() {
        this.f340r = 0;
    }

    public void J() {
        this.f340r = 2;
    }

    public void K(i.a aVar, int i6) {
        L(aVar, i6, o.class);
    }

    public void L(i.a aVar, int i6, Class cls) {
        this.f341s = aVar;
        this.f340r = i6;
        x();
        this.f344v = cls;
    }

    public void M(String str, String str2) {
        K(new i.a(str, str2), 0);
    }

    public void N(int i6) {
    }

    public void O(float f6, String str, long j6, String str2, long j7) {
    }

    public void P(float f6, int i6) {
    }

    public void Q() {
    }

    public void R() {
        Log.i("JZVD", "startProgressTimer:  [" + hashCode() + "] ");
        c();
        this.N = new Timer();
        b bVar = new b();
        this.R = bVar;
        this.N.schedule(bVar, 0L, 300L);
    }

    public void S() {
        Log.d("JZVD", "startVideo [" + hashCode() + "] ");
        setCurrentJzvd(this);
        try {
            this.f345w = (i.b) this.f344v.getConstructor(Jzvd.class).newInstance(this);
        } catch (IllegalAccessException e6) {
            e6.printStackTrace();
        } catch (InstantiationException e7) {
            e7.printStackTrace();
        } catch (NoSuchMethodException e8) {
            e8.printStackTrace();
        } catch (InvocationTargetException e9) {
            e9.printStackTrace();
        }
        a();
        p.j(getContext()).getWindow().addFlags(128);
        A();
    }

    protected void T(float f6, float f7) {
        Log.i("JZVD", "onTouch surfaceContainer actionDown [" + hashCode() + "] ");
        this.S = true;
        this.T = f6;
        this.U = f7;
        this.V = false;
        this.W = false;
        this.f328b0 = false;
    }

    protected void U(float f6, float f7) {
        Log.i("JZVD", "onTouch surfaceContainer actionMove [" + hashCode() + "] ");
        float f8 = f6 - this.T;
        float f9 = f7 - this.U;
        float abs = Math.abs(f8);
        float abs2 = Math.abs(f9);
        if (this.f340r == 1) {
            if (this.T <= p.c(getContext()) && this.U >= p.d(getContext())) {
                if (!this.W && !this.V && !this.f328b0 && (abs > 80.0f || abs2 > 80.0f)) {
                    c();
                    if (abs >= 80.0f) {
                        if (this.f339q != 8) {
                            this.W = true;
                            this.f329c0 = getCurrentPositionWhenPlaying();
                        }
                    } else if (this.T < this.P * 0.5f) {
                        this.f328b0 = true;
                        float f10 = p.e(getContext()).getAttributes().screenBrightness;
                        if (f10 < 0.0f) {
                            try {
                                this.f331e0 = Settings.System.getInt(getContext().getContentResolver(), "screen_brightness");
                                Log.i("JZVD", "current system brightness: " + this.f331e0);
                            } catch (Settings.SettingNotFoundException e6) {
                                e6.printStackTrace();
                            }
                        } else {
                            this.f331e0 = f10 * 255.0f;
                            Log.i("JZVD", "current activity brightness: " + this.f331e0);
                        }
                    } else {
                        this.V = true;
                        this.f330d0 = this.Q.getStreamVolume(3);
                    }
                }
            } else {
                return;
            }
        }
        if (this.W) {
            long duration = getDuration();
            if (f326x0 <= 0.0f) {
                Log.d("JZVD", "error PROGRESS_DRAG_RATE value");
                f326x0 = 1.0f;
            }
            long j6 = (int) (((float) this.f329c0) + ((((float) duration) * f8) / (this.O * f326x0)));
            this.f332f0 = j6;
            if (j6 > duration) {
                this.f332f0 = duration;
            }
            O(f8, p.n(this.f332f0), this.f332f0, p.n(duration), duration);
        }
        if (this.V) {
            f9 = -f9;
            this.Q.setStreamVolume(3, this.f330d0 + ((int) (((this.Q.getStreamMaxVolume(3) * f9) * 3.0f) / this.P)), 0);
            P(-f9, (int) (((this.f330d0 * 100) / r14) + (((f9 * 3.0f) * 100.0f) / this.P)));
        }
        if (this.f328b0) {
            float f11 = -f9;
            WindowManager.LayoutParams attributes = p.e(getContext()).getAttributes();
            float f12 = this.f331e0;
            float f13 = (int) (((f11 * 255.0f) * 3.0f) / this.P);
            if ((f12 + f13) / 255.0f >= 1.0f) {
                attributes.screenBrightness = 1.0f;
            } else if ((f12 + f13) / 255.0f <= 0.0f) {
                attributes.screenBrightness = 0.01f;
            } else {
                attributes.screenBrightness = (f12 + f13) / 255.0f;
            }
            p.e(getContext()).setAttributes(attributes);
            N((int) (((this.f331e0 * 100.0f) / 255.0f) + (((f11 * 3.0f) * 100.0f) / this.P)));
        }
    }

    protected void V() {
        Log.i("JZVD", "onTouch surfaceContainer actionUp [" + hashCode() + "] ");
        this.S = false;
        j();
        k();
        i();
        if (this.W) {
            this.f345w.e(this.f332f0);
            long duration = getDuration();
            long j6 = this.f332f0 * 100;
            if (duration == 0) {
                duration = 1;
            }
            this.C.setProgress((int) (j6 / duration));
        }
        R();
    }

    public void a() {
        Log.d("JZVD", "addTextureView [" + hashCode() + "] ");
        JZTextureView jZTextureView = this.J;
        if (jZTextureView != null) {
            this.G.removeView(jZTextureView);
        }
        JZTextureView jZTextureView2 = new JZTextureView(getContext().getApplicationContext());
        this.J = jZTextureView2;
        jZTextureView2.setSurfaceTextureListener(this.f345w);
        this.G.addView(this.J, new FrameLayout.LayoutParams(-1, -1, 17));
    }

    public void c() {
        Timer timer = this.N;
        if (timer != null) {
            timer.cancel();
        }
        b bVar = this.R;
        if (bVar != null) {
            bVar.cancel();
        }
    }

    public void d(i.a aVar, long j6) {
        this.f341s = aVar;
        this.A = j6;
        B();
    }

    public void e() {
        p.l(getContext());
        p.k(getContext(), f319q0);
        p.m(getContext());
        ((ViewGroup) p.j(getContext()).getWindow().getDecorView()).removeView(this);
        i.b bVar = this.f345w;
        if (bVar != null) {
            bVar.d();
        }
        f315m0 = null;
    }

    protected void f() {
        Log.i("JZVD", "onClick fullscreen [" + hashCode() + "] ");
        if (this.f339q == 7) {
            return;
        }
        if (this.f340r == 1) {
            b();
            return;
        }
        Log.d("JZVD", "toFullscreenActivity [" + hashCode() + "] ");
        l();
    }

    protected void g() {
        Log.i("JZVD", "onClick start [" + hashCode() + "] ");
        i.a aVar = this.f341s;
        if (aVar != null && !aVar.f22811b.isEmpty() && this.f341s.c() != null) {
            int i6 = this.f339q;
            if (i6 == 0) {
                if (!this.f341s.c().toString().startsWith("file") && !this.f341s.c().toString().startsWith("/") && !p.h(getContext()) && !f321s0) {
                    Q();
                    return;
                } else {
                    S();
                    return;
                }
            }
            if (i6 == 5) {
                Log.d("JZVD", "pauseVideo [" + hashCode() + "] ");
                this.f345w.c();
                y();
                return;
            }
            if (i6 == 6) {
                this.f345w.f();
                z();
                return;
            } else {
                if (i6 == 7) {
                    S();
                    return;
                }
                return;
            }
        }
        Toast.makeText(getContext(), getResources().getString(R.string.no_url), 0).show();
    }

    public Context getApplicationContext() {
        Context applicationContext;
        Context context = getContext();
        if (context != null && (applicationContext = context.getApplicationContext()) != null) {
            return applicationContext;
        }
        return context;
    }

    public long getCurrentPositionWhenPlaying() {
        int i6 = this.f339q;
        if (i6 != 5 && i6 != 6 && i6 != 3) {
            return 0L;
        }
        try {
            return this.f345w.a();
        } catch (IllegalStateException e6) {
            e6.printStackTrace();
            return 0L;
        }
    }

    public long getDuration() {
        try {
            return this.f345w.b();
        } catch (Exception e6) {
            e6.printStackTrace();
            return 0L;
        }
    }

    public abstract int getLayoutId();

    public void h(ViewGroup viewGroup) {
        try {
            Jzvd jzvd = (Jzvd) getClass().getConstructor(Context.class).newInstance(getContext());
            jzvd.setId(getId());
            jzvd.setMinimumWidth(this.f337k0);
            jzvd.setMinimumHeight(this.f338l0);
            viewGroup.addView(jzvd, this.f336j0, this.f335i0);
            jzvd.L(this.f341s.a(), 0, this.f344v);
        } catch (IllegalAccessException e6) {
            e6.printStackTrace();
        } catch (InstantiationException e7) {
            e7.printStackTrace();
        } catch (NoSuchMethodException e8) {
            e8.printStackTrace();
        } catch (InvocationTargetException e9) {
            e9.printStackTrace();
        }
    }

    public void i() {
    }

    public void j() {
    }

    public void k() {
    }

    public void l() {
        this.M = System.currentTimeMillis();
        ViewGroup viewGroup = (ViewGroup) getParent();
        this.f333g0 = viewGroup.getContext();
        this.f335i0 = getLayoutParams();
        this.f336j0 = viewGroup.indexOfChild(this);
        this.f337k0 = getWidth();
        this.f338l0 = getHeight();
        viewGroup.removeView(this);
        h(viewGroup);
        f316n0.add(viewGroup);
        ((ViewGroup) p.j(this.f333g0).getWindow().getDecorView()).addView(this, new FrameLayout.LayoutParams(-1, -1));
        H();
        p.f(this.f333g0);
        p.k(this.f333g0, f318p0);
        p.g(this.f333g0);
    }

    public void m() {
        this.L = System.currentTimeMillis();
        ((ViewGroup) p.j(this.f333g0).getWindow().getDecorView()).removeView(this);
        this.G.removeView(this.J);
        f316n0.getLast().removeViewAt(this.f336j0);
        f316n0.getLast().addView(this, this.f336j0, this.f335i0);
        f316n0.pop();
        I();
        p.l(this.f333g0);
        p.k(this.f333g0, f319q0);
        p.m(this.f333g0);
    }

    public void n() {
        this.L = System.currentTimeMillis();
        ((ViewGroup) p.j(this.f333g0).getWindow().getDecorView()).removeView(this);
        f316n0.getLast().removeViewAt(this.f336j0);
        f316n0.getLast().addView(this, this.f336j0, this.f335i0);
        f316n0.pop();
        I();
        p.l(this.f333g0);
        p.k(this.f333g0, f319q0);
        p.m(this.f333g0);
    }

    public void o(Context context) {
        View.inflate(context, getLayoutId(), this);
        this.f333g0 = context;
        this.B = (ImageView) findViewById(R.id.start);
        this.D = (ImageView) findViewById(R.id.fullscreen);
        this.C = (SeekBar) findViewById(R.id.bottom_seek_progress);
        this.E = (TextView) findViewById(R.id.current);
        this.F = (TextView) findViewById(R.id.total);
        this.I = (ViewGroup) findViewById(R.id.layout_bottom);
        this.G = (ViewGroup) findViewById(R.id.surface_container);
        this.H = (ViewGroup) findViewById(R.id.layout_top);
        if (this.B == null) {
            this.B = new ImageView(context);
        }
        if (this.D == null) {
            this.D = new ImageView(context);
        }
        if (this.C == null) {
            this.C = new SeekBar(context);
        }
        if (this.E == null) {
            this.E = new TextView(context);
        }
        if (this.F == null) {
            this.F = new TextView(context);
        }
        if (this.I == null) {
            this.I = new LinearLayout(context);
        }
        if (this.G == null) {
            this.G = new FrameLayout(context);
        }
        if (this.H == null) {
            this.H = new RelativeLayout(context);
        }
        this.B.setOnClickListener(this);
        this.D.setOnClickListener(this);
        this.C.setOnSeekBarChangeListener(this);
        this.I.setOnClickListener(this);
        this.G.setOnClickListener(this);
        this.G.setOnTouchListener(this);
        this.O = getContext().getResources().getDisplayMetrics().widthPixels;
        this.P = getContext().getResources().getDisplayMetrics().heightPixels;
        this.f339q = -1;
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.start) {
            g();
        } else if (id == R.id.fullscreen) {
            f();
        }
    }

    @Override
    protected void onMeasure(int i6, int i7) {
        int i8 = this.f340r;
        if (i8 != 1 && i8 != 2) {
            if (this.f342t != 0 && this.f343u != 0) {
                int size = View.MeasureSpec.getSize(i6);
                int i9 = (int) ((size * this.f343u) / this.f342t);
                setMeasuredDimension(size, i9);
                getChildAt(0).measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(i9, 1073741824));
                return;
            }
            super.onMeasure(i6, i7);
            return;
        }
        super.onMeasure(i6, i7);
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int i6, boolean z6) {
        if (z6) {
            this.E.setText(p.n((i6 * 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() + "] ");
        R();
        for (ViewParent parent = getParent(); parent != null; parent = parent.getParent()) {
            parent.requestDisallowInterceptTouchEvent(false);
        }
        int i6 = this.f339q;
        if (i6 != 5 && i6 != 6) {
            return;
        }
        long progress = (seekBar.getProgress() * getDuration()) / 100;
        this.f348z = seekBar.getProgress();
        this.f345w.e(progress);
        Log.i("JZVD", "seekTo " + progress + " [" + hashCode() + "] ");
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        float x6 = motionEvent.getX();
        float y6 = motionEvent.getY();
        if (view.getId() == R.id.surface_container) {
            int action = motionEvent.getAction();
            if (action != 0) {
                if (action != 1) {
                    if (action == 2) {
                        U(x6, y6);
                        return false;
                    }
                    return false;
                }
                V();
                return false;
            }
            T(x6, y6);
            return false;
        }
        return false;
    }

    public void p() {
        Runtime.getRuntime().gc();
        Log.i("JZVD", "onAutoCompletion  [" + hashCode() + "] ");
        c();
        i();
        j();
        k();
        v();
        this.f345w.d();
        p.j(getContext()).getWindow().clearFlags(128);
        p.i(getContext(), this.f341s.c(), 0L);
        if (this.f340r == 1) {
            if (f316n0.size() == 0) {
                e();
            } else {
                m();
            }
        }
    }

    public void q(int i6, int i7) {
        Log.e("JZVD", "onError " + i6 + " - " + i7 + " [" + hashCode() + "] ");
        if (i6 != 38 && i7 != -38 && i6 != -38 && i7 != 38 && i7 != -19) {
            w();
            this.f345w.d();
        }
    }

    public void r(int i6, int i7) {
        Log.d("JZVD", "onInfo what - " + i6 + " extra - " + i7);
        if (i6 == 3) {
            Log.d("JZVD", "MEDIA_INFO_VIDEO_RENDERING_START");
            int i8 = this.f339q;
            if (i8 == 4 || i8 == 2 || i8 == 3) {
                z();
                return;
            }
            return;
        }
        if (i6 == 701) {
            Log.d("JZVD", "MEDIA_INFO_BUFFERING_START");
            f325w0 = this.f339q;
            setState(3);
        } else if (i6 == 702) {
            Log.d("JZVD", "MEDIA_INFO_BUFFERING_END");
            int i9 = f325w0;
            if (i9 != -1) {
                setState(i9);
                f325w0 = -1;
            }
        }
    }

    public void s() {
        Log.i("JZVD", "onPrepared  [" + hashCode() + "] ");
        this.f339q = 4;
        if (!this.K) {
            this.f345w.f();
            this.K = false;
        }
        if (this.f341s.c().toString().toLowerCase().contains("mp3") || this.f341s.c().toString().toLowerCase().contains("wma") || this.f341s.c().toString().toLowerCase().contains("aac") || this.f341s.c().toString().toLowerCase().contains("m4a") || this.f341s.c().toString().toLowerCase().contains("wav")) {
            z();
        }
    }

    public void setBufferProgress(int i6) {
        this.C.setSecondaryProgress(i6);
    }

    public void setMediaInterface(Class cls) {
        F();
        this.f344v = cls;
    }

    public void setScreen(int i6) {
        if (i6 != 0) {
            if (i6 != 1) {
                if (i6 == 2) {
                    J();
                    return;
                }
                return;
            }
            H();
            return;
        }
        I();
    }

    public void setState(int i6) {
        switch (i6) {
            case 0:
                x();
                return;
            case 1:
                A();
                return;
            case 2:
                B();
                return;
            case 3:
                C();
                return;
            case 4:
            default:
                return;
            case 5:
                z();
                return;
            case 6:
                y();
                return;
            case 7:
                v();
                return;
            case 8:
                w();
                return;
        }
    }

    public void t(int i6, long j6, long j7) {
        this.f334h0 = j6;
        if (!this.S) {
            int i7 = this.f348z;
            if (i7 != -1) {
                if (i7 > i6) {
                    return;
                } else {
                    this.f348z = -1;
                }
            } else {
                this.C.setProgress(i6);
            }
        }
        if (j6 != 0) {
            this.E.setText(p.n(j6));
        }
        this.F.setText(p.n(j7));
    }

    public void u() {
    }

    public void v() {
        Log.i("JZVD", "onStateAutoComplete  [" + hashCode() + "] ");
        this.f339q = 7;
        c();
        this.C.setProgress(100);
        this.E.setText(this.F.getText());
    }

    public void w() {
        Log.i("JZVD", "onStateError  [" + hashCode() + "] ");
        this.f339q = 8;
        c();
    }

    public void x() {
        Log.i("JZVD", "onStateNormal  [" + hashCode() + "] ");
        this.f339q = 0;
        c();
        i.b bVar = this.f345w;
        if (bVar != null) {
            bVar.d();
        }
    }

    public void y() {
        Log.i("JZVD", "onStatePause  [" + hashCode() + "] ");
        this.f339q = 6;
        R();
    }

    public void z() {
        Log.i("JZVD", "onStatePlaying  [" + hashCode() + "] ");
        if (this.f339q == 4) {
            Log.d("JZVD", "onStatePlaying:STATE_PREPARED ");
            AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(MimeTypes.BASE_TYPE_AUDIO);
            this.Q = audioManager;
            audioManager.requestAudioFocus(f327y0, 3, 2);
            long j6 = this.A;
            if (j6 != 0) {
                this.f345w.e(j6);
                this.A = 0L;
            } else {
                long b6 = p.b(getContext(), this.f341s.c());
                if (b6 != 0) {
                    this.f345w.e(b6);
                }
            }
        }
        this.f339q = 5;
        R();
    }
}