package xyz.netfly.ui.live.tablet;

import ag.c;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.media3.exoplayer.audio.g;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import com.google.android.gms.internal.ads.p80;
import com.pichillilorenzo.flutter_inappwebview_android.credential_database.URLProtectionSpaceContract;
import ie.k;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import kotlinx.coroutines.y;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import re.a;
import rf.w;
import te.d;
import te.f;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.MediaSource;
import tv.danmaku.ijk.media.player.misc.ITrackInfo;
import tv.danmaku.ijk.media.player.ui.IjkPlayerRuntime;
import tv.danmaku.ijk.media.player.ui.IjkVideoView;
import tv.danmaku.ijk.media.player.ui.abr.AbrController;
import ve.v;
import xe.b;
import xyz.netfly.ads.r;
import xyz.netfly.mobile.player.x;
import xyz.netfly.player.i;
import xyz.stream.api.entity.LiveChannelEntity;
import xyz.stream.api.q;
import xyz.stream.api.viewmodel.LiveViewModel;
import xyz.stream.utils.e;
import xyz.stream.utils.event.LogoutEvent;
import xyz.stream.utils.f0;
import xyz.stream.utils.h;
import xyz.stream.utils.j0;
import xyz.stream.utils.l;
import xyz.stream.view.BaseActivity;
import xyz.stream.view.UiUtils;
import xyz.stream.view.VideoGestureFrameLayout;

/* JADX INFO: loaded from: classes3.dex */
public class LivePlayActivity extends BaseActivity<LiveViewModel, k> implements c, IMediaPlayer.Listener, View.OnKeyListener, b, VideoGestureFrameLayout.VideoGestureListener {

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public static final /* synthetic */ int f35447f0 = 0;
    public int S;
    public String U;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public p80 f35451c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public IjkVideoView f35453d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public LiveChannelEntity f35455e;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f35459h;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public ITrackInfo f35462k;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final v f35449b = new v();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public String f35457f = "";

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f35458g = false;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f35460i = false;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final Handler f35461j = new Handler(Looper.getMainLooper());

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public boolean f35463l = false;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public String f35464m = "";
    public final ArrayList Q = new ArrayList();
    public boolean R = false;
    public long T = 0;
    public final ExecutorService V = Executors.newSingleThreadExecutor();
    public int W = 0;
    public final f X = new f(this, 0);
    public final te.c Y = new te.c(this, 0);
    public int Z = -1;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public final Handler f35448a0 = new Handler(Looper.getMainLooper());

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public final f f35450b0 = new f(this, 1);

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public int f35452c0 = -1;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public String f35454d0 = "";

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public String f35456e0 = "";

    @Override // xe.b
    public final void B() {
    }

    @Override // xe.b
    public final void D() {
        LiveChannelEntity liveChannelEntityL = this.f35449b.l(this.f35455e);
        if (liveChannelEntityL != null) {
            a.u().getClass();
            if (a.t(liveChannelEntityL) > 1) {
                y.a0(this);
                return;
            }
            M();
            LiveChannelEntity liveChannelEntity = this.f35455e;
            if (liveChannelEntity != null && this.f35453d != null) {
                l.a(liveChannelEntity.getId().intValue(), y.l(this.f35453d.getTotalByte()), this.f35457f);
            }
            this.f35455e = liveChannelEntityL;
            this.f35458g = false;
            xyz.netfly.api.c.b().c();
            initView();
        }
    }

    public final void K() {
        if (this.f35455e == null) {
            return;
        }
        VB vb2 = this.binding;
        if (vb2 != 0) {
            ((k) vb2).f27110p.setVisibility(8);
        }
        if (System.currentTimeMillis() - this.T > 3600000 && this.f35453d.getPlaybackState() != -1) {
            this.f35453d.setVisibility(8);
            if (e.d().f36119h) {
                r.e().g(6, this, new d(this));
            }
        }
        ((k) this.binding).f27097c.requestFocus();
        ((k) this.binding).f27097c.setFocusable(true);
        ((k) this.binding).f27097c.setFocusableInTouchMode(true);
        if (this.f35453d.getPlaybackState() == -1 && r.e().f34892g) {
            ((k) this.binding).f27113s.setVisibility(8);
        } else {
            ((k) this.binding).f27113s.setVisibility(0);
        }
        this.Q.clear();
        IjkVideoView ijkVideoView = this.f35453d;
        if (ijkVideoView != null) {
            ijkVideoView.removeListener();
            this.f35453d.stop();
            this.f35453d.release();
        }
        int iP = f0.o().p("sp_live_video_ratio", 4);
        this.f35453d.setResizeMode(iP);
        LinkedHashMap linkedHashMapR = w.r(this);
        if (linkedHashMapR.containsKey(Integer.valueOf(iP))) {
            ((k) this.binding).f27104j.getRatioText().setText((CharSequence) linkedHashMapR.get(Integer.valueOf(iP)));
        }
        this.f35453d.setPlayer(this.f35455e.getProtocol() == 1 ? 1 : 2);
        this.f35453d.setSubtitleSizePx(UiUtils.playerSubtitleSizePx(this, f0.o().p(IjkPlayerRuntime.SP_SUBTITLE_SIZE, 50)));
        this.f35453d.decode(1);
        this.f35453d.setVolume(1.0f, 1.0f);
        String strH = this.R ? v.h(this.f35455e) : v.i(this.f35455e);
        this.f35464m = strH;
        if (strH == null || strH.isEmpty()) {
            this.f35464m = v.i(this.f35455e);
        }
        if (this.f35455e.getId() == null) {
            this.f35456e0 = "0-0";
            h.c("live channel id is null, url: " + this.f35464m);
            N();
            return;
        }
        int i10 = this.W + 1;
        this.W = i10;
        int iIntValue = this.f35455e.getId().intValue();
        String str = this.f35464m;
        if (e.g(str)) {
            this.V.execute(new x(this, iIntValue, str, i10));
        } else {
            L(iIntValue, i10, str, str);
        }
    }

    public final void L(int i10, int i11, String str, String str2) {
        LiveChannelEntity liveChannelEntity;
        if (isFinishing() || isDestroyed() || this.binding == 0 || this.f35453d == null || (liveChannelEntity = this.f35455e) == null || i11 != this.W || !Objects.equals(liveChannelEntity.getId(), Integer.valueOf(i10))) {
            return;
        }
        this.U = str;
        if (str == null || str.isEmpty()) {
            this.f35456e0 = "0-0";
            h.c("live play url is empty, channelId: " + i10 + " url: " + str2);
            N();
            return;
        }
        xyz.netfly.api.c.b().p(6, i10, UUID.randomUUID().toString(), str2);
        HashMap map = new HashMap();
        map.put(URLProtectionSpaceContract.FeedEntry.COLUMN_NAME_PROTOCOL, String.valueOf(this.f35455e.getProtocol()));
        a aVarU = a.u();
        LiveChannelEntity liveChannelEntity2 = this.f35455e;
        aVarU.getClass();
        map.put("is_premium", a.t(liveChannelEntity2) > 0 ? "1" : SessionDescription.SUPPORTED_SDP_VERSION);
        if (this.f35455e.getCategoryProperty() != null && this.f35455e.getCategoryProperty().equals("Sports")) {
            map.put("is_sports", "1");
        }
        map.put("channel_id", String.valueOf(this.f35455e.getId()));
        this.f35453d.setMediaSourceLive(new MediaSource(map, Uri.parse(this.U)));
        p80 p80Var = this.f35451c;
        if (p80Var != null) {
            p80Var.b();
        }
        p80 p80Var2 = new p80(this, ((k) this.binding).f27118x, this.U);
        this.f35451c = p80Var2;
        p80Var2.d();
        this.f35451c.e();
        this.f35451c.f();
        this.f35451c.f15297e = this;
        initListener();
    }

    public final void M() {
        this.W++;
        p80 p80Var = this.f35451c;
        if (p80Var != null) {
            p80Var.f15297e = null;
        }
        IjkVideoView ijkVideoView = this.f35453d;
        if (ijkVideoView != null) {
            ijkVideoView.removeListener();
        }
        this.f35449b.f33928h = null;
        this.f35448a0.removeCallbacksAndMessages(null);
        this.f35461j.removeCallbacksAndMessages(null);
        p80 p80Var2 = this.f35451c;
        if (p80Var2 != null) {
            p80Var2.b();
        }
        if (this.f35455e != null) {
            q.g().b(this.U);
        }
        IjkVideoView ijkVideoView2 = this.f35453d;
        if (ijkVideoView2 != null) {
            ijkVideoView2.removeListener();
            this.f35453d.stop();
            this.f35453d.release();
        }
    }

    public final void N() {
        VB vb2 = this.binding;
        if (vb2 == 0) {
            return;
        }
        ((k) vb2).f27113s.setVisibility(8);
        ((k) this.binding).f27112r.setText("Sorry, your current channel failed to load.");
        TextView textView = ((k) this.binding).f27111q;
        StringBuilder sb = new StringBuilder("Error code ");
        String str = this.f35456e0;
        sb.append((str == null || str.isEmpty()) ? String.valueOf(this.f35452c0) : this.f35456e0);
        sb.append(".");
        textView.setText(sb.toString());
        ((k) this.binding).f27110p.setVisibility(0);
        ((k) this.binding).f27097c.setOnKeyListener(this);
        ((k) this.binding).f27097c.requestFocus();
    }

    @Override // xyz.stream.view.BaseActivity
    public final v3.a getViewBinding() {
        return k.inflate(getLayoutInflater(), null, false);
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initListener() {
        this.f35453d.addListener(this);
        ((k) this.binding).f27104j.getBtnMenu().setOnClickListener(new com.google.android.material.textfield.b(this, 13));
        this.f35449b.f33928h = this;
        ((k) this.binding).f27097c.setOnKeyListener(this);
        ((k) this.binding).f27097c.setVideoGestureListener(this);
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initView() {
        xyz.stream.utils.f.p().x("Live page setPlayer");
        getWindow().addFlags(128);
        boolean z10 = false;
        int i10 = 1;
        if (e.d().f36119h) {
            UiUtils.setUnFocusable(((k) this.binding).f27103i);
        }
        if (f0.o().j("flutter.spShowBitrate", Boolean.FALSE)) {
            ((k) this.binding).f27115u.setVisibility(0);
        } else {
            ((k) this.binding).f27115u.setVisibility(8);
        }
        this.f35457f = kotlinx.coroutines.flow.h.C();
        this.f35459h = 10;
        this.f35456e0 = "";
        VB vb2 = this.binding;
        if (vb2 != 0) {
            ((k) vb2).f27110p.setVisibility(8);
        }
        ((k) this.binding).f27097c.initView(this);
        if (this.f35455e == null) {
            this.f35455e = (LiveChannelEntity) getIntent().getParcelableExtra("channel");
            this.S = getIntent().getIntExtra("groupId", this.f35455e.getCategoryId().intValue());
        }
        LiveChannelEntity liveChannelEntity = this.f35455e;
        if (liveChannelEntity != null) {
            this.f35449b.n(this, (LiveViewModel) this.viewModel, (k) this.binding, liveChannelEntity, null, null, null, this.S);
            this.f35449b.t();
            a.u().e(new oe.f(this, 2));
            xyz.netfly.ui.live.epg.q qVarO = xyz.netfly.ui.live.epg.q.o();
            int iIntValue = this.f35455e.getId().intValue();
            i iVar = new i(this, i10);
            qVarO.getClass();
            qVarO.l(iIntValue, kotlinx.coroutines.flow.h.y("yyyy-MM-dd"), iVar);
        }
        IjkVideoView ijkVideoView = this.f35453d;
        if (ijkVideoView != null) {
            ijkVideoView.stop();
            this.f35453d.release();
        } else {
            this.f35453d = ((k) this.binding).f27118x;
        }
        if (!this.f35463l) {
            this.f35463l = true;
            xyz.netfly.api.c cVarB = xyz.netfly.api.c.b();
            IjkVideoView ijkVideoView2 = this.f35453d;
            LiveChannelEntity liveChannelEntity2 = this.f35455e;
            if (liveChannelEntity2 != null && liveChannelEntity2.getIsIptv() == 1) {
                z10 = true;
            }
            cVarB.getClass();
            cVarB.f34905f = new WeakReference(ijkVideoView2);
            cVarB.f34904e = z10;
        }
        K();
    }

    @Override // xe.b
    public final void l() {
        LiveChannelEntity liveChannelEntityJ = this.f35449b.j(this.f35455e);
        if (liveChannelEntityJ != null) {
            a.u().getClass();
            if (a.t(liveChannelEntityJ) > 1) {
                y.a0(this);
                return;
            }
            M();
            LiveChannelEntity liveChannelEntity = this.f35455e;
            if (liveChannelEntity != null && this.f35453d != null) {
                l.a(liveChannelEntity.getId().intValue(), y.l(this.f35453d.getTotalByte()), this.f35457f);
            }
            this.f35455e = liveChannelEntityJ;
            this.f35458g = false;
            xyz.netfly.api.c.b().c();
            initView();
        }
    }

    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, android.app.Activity
    public void onActivityResult(int i10, int i11, @Nullable Intent intent) {
        super.onActivityResult(i10, i11, intent);
        if (i10 == 100 && i11 == 100) {
            if (intent == null) {
                this.f35449b.p();
                return;
            }
            LiveChannelEntity liveChannelEntity = (LiveChannelEntity) intent.getParcelableExtra("channel");
            this.S = intent.getIntExtra("groupId", this.f35455e.getCategoryId().intValue());
            if (liveChannelEntity != null) {
                if (Objects.equals(liveChannelEntity.getId(), this.f35455e.getId()) && Objects.equals(liveChannelEntity.getCategoryId(), this.f35455e.getCategoryId())) {
                    return;
                }
                M();
                LiveChannelEntity liveChannelEntity2 = this.f35455e;
                if (liveChannelEntity2 != null && this.f35453d != null) {
                    l.a(liveChannelEntity2.getId().intValue(), y.l(this.f35453d.getTotalByte()), this.f35457f);
                }
                this.f35455e = liveChannelEntity;
                this.f35458g = false;
                xyz.netfly.api.c.b().c();
                initView();
            }
        }
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onAudioTrackSelect(ITrackInfo iTrackInfo) {
        super.onAudioTrackSelect(iTrackInfo);
        if (isFinishing() || isDestroyed()) {
            M();
        }
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onBitrateChange(int i10, long j10, long j11) {
        if (isFinishing() || isDestroyed()) {
            return;
        }
        runOnUiThread(new g(this, i10, j10, j11, 2));
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onCompletion(IMediaPlayer iMediaPlayer) {
        if (isFinishing() || isDestroyed() || this.binding == 0 || this.f35459h != 10 || isFinishing() || isDestroyed()) {
            return;
        }
        K();
    }

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onDestroy() {
        M();
        j0.k().p(this);
        r.e().d();
        xyz.netfly.api.c.b().c();
        xyz.netfly.api.c.b().f();
        xyz.netfly.api.c.b().s();
        xyz.netfly.ui.live.epg.q.o().c();
        this.f35461j.removeCallbacksAndMessages(null);
        getWindow().clearFlags(128);
        this.W++;
        this.V.shutdownNow();
        LiveChannelEntity liveChannelEntity = this.f35455e;
        if (liveChannelEntity != null && this.f35453d != null) {
            l.a(liveChannelEntity.getId().intValue(), y.l(this.f35453d.getTotalByte()), this.f35457f);
        }
        this.f35449b.b();
        IjkVideoView ijkVideoView = this.f35453d;
        if (ijkVideoView != null) {
            try {
                ViewParent parent = ijkVideoView.getParent();
                if (parent instanceof ViewGroup) {
                    ((ViewGroup) parent).removeView(this.f35453d);
                }
            } catch (Throwable unused) {
            }
            try {
                this.f35453d.removeListener();
            } catch (Throwable unused2) {
            }
            try {
                this.f35453d.stop();
            } catch (Throwable unused3) {
            }
            try {
                this.f35453d.release();
            } catch (Throwable unused4) {
            }
            this.f35453d = null;
        }
        super.onDestroy();
    }

    @Override // xyz.stream.view.VideoGestureFrameLayout.VideoGestureListener
    public final void onDoubleTapGesture(MotionEvent motionEvent) {
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final boolean onError(IMediaPlayer iMediaPlayer, int i10, int i11, String str) {
        StringBuilder sbR = defpackage.e.r("live play error:", i10, " extra:", i11, " url: ");
        sbR.append(this.f35464m);
        h.c(sbR.toString());
        this.f35452c0 = i10;
        this.f35456e0 = i10 + "-" + i11;
        this.f35454d0 = str;
        if (r.e().f34892g) {
            return true;
        }
        if (i10 == 100333 && i11 == 100333) {
            y.a0(this);
            return true;
        }
        synchronized (this) {
            this.f35448a0.removeCallbacks(this.f35450b0);
            this.f35448a0.postDelayed(this.f35450b0, 1000L);
        }
        return false;
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onInfo(IMediaPlayer iMediaPlayer, int i10, int i11) {
        if (isFinishing() || isDestroyed() || this.binding == 0) {
            return;
        }
        Handler handler = this.f35461j;
        te.c cVar = this.Y;
        f fVar = this.X;
        if (i10 == 701) {
            handler.removeCallbacks(fVar);
            handler.removeCallbacks(cVar);
            handler.postDelayed(fVar, 200L);
            return;
        }
        if (i10 == 702 || i10 == 10008) {
            handler.removeCallbacks(fVar);
            handler.removeCallbacks(cVar);
            ((k) this.binding).f27113s.setVisibility(8);
            this.f35451c.c();
            if (this.Z == i10) {
                return;
            }
            this.Z = i10;
            xyz.netfly.api.c.b().j();
            return;
        }
        if (i10 == 3) {
            xyz.netfly.api.c.b().r();
            this.f35459h = 10;
            if (this.f35458g) {
                return;
            }
            this.f35458g = true;
            l.f36161a.execute(new xyz.stream.utils.i(this.f35457f, kotlinx.coroutines.flow.h.C(), this.f35455e.getId().intValue(), this.f35455e.getName()));
            this.f35462k = this.f35453d.getSelectVideoTrackInfo();
        }
    }

    @Override // android.view.View.OnKeyListener
    public final boolean onKey(View view, int i10, KeyEvent keyEvent) {
        return false;
    }

    @Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i10, KeyEvent keyEvent) {
        if (i10 != 4 || keyEvent.getAction() != 0) {
            return super.onKeyDown(i10, keyEvent);
        }
        if (this.f35460i) {
            return true;
        }
        this.f35460i = true;
        if (((k) this.binding).f27103i.getVisibility() != 0) {
            finish();
            return true;
        }
        this.f35449b.m();
        this.f35460i = false;
        return true;
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onLoadedData(String str, long j10, int i10, int i11, int i12, String str2) {
        super.onLoadedData(str, j10, i10, i11, i12, str2);
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("width", Integer.valueOf(i11));
        linkedHashMap.put("height", Integer.valueOf(i12));
        linkedHashMap.put("bandwidth", Long.valueOf(j10));
        linkedHashMap.put("frameRate", Integer.valueOf(i10));
        linkedHashMap.put("codecs", str2);
        xyz.netfly.api.c.b().g(str, linkedHashMap);
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onLog(IMediaPlayer iMediaPlayer, String str) {
    }

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void onMessageEvent(LogoutEvent logoutEvent) {
        uf.r.j(this, new d(this));
    }

    @Override // androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onPause() {
        super.onPause();
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onPrepared(IMediaPlayer iMediaPlayer) {
        VB vb2;
        LiveChannelEntity liveChannelEntity;
        if (isFinishing() || isDestroyed() || (vb2 = this.binding) == 0) {
            return;
        }
        ((k) vb2).f27113s.setVisibility(8);
        if (!r.e().f34892g) {
            this.f35453d.setVolume(1.0f, 1.0f);
        }
        v vVar = this.f35449b;
        if (vVar == null || (liveChannelEntity = vVar.f33927g) == null) {
            return;
        }
        int i10 = 1;
        if (liveChannelEntity.getIsAdult() == 1) {
            return;
        }
        new Thread(new te.e(vVar, i10)).start();
    }

    @Override // android.app.Activity
    public final void onRestart() {
        super.onRestart();
        ((k) this.binding).f27113s.setVisibility(0);
        K();
        initListener();
    }

    @Override // xyz.stream.view.VideoGestureFrameLayout.VideoGestureListener
    public final void onSingleTapGesture(MotionEvent motionEvent) {
        this.f35449b.u();
    }

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onStart() {
        super.onStart();
        j0.k().o(this, new d(this));
    }

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onStop() {
        IjkVideoView ijkVideoView;
        super.onStop();
        if (r.e().f34892g) {
            return;
        }
        h.b("Live page onStop");
        if (isFinishing() && (ijkVideoView = this.f35453d) != null && ijkVideoView.getPlaybackState() == 1) {
            xyz.netfly.api.c.b().i();
        }
        M();
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onSubtitleTrackSelect(ITrackInfo iTrackInfo) {
        super.onSubtitleTrackSelect(iTrackInfo);
        if (isFinishing() || isDestroyed()) {
            M();
        }
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onVideoTrackSelect(ITrackInfo iTrackInfo) {
        if (isFinishing() || isDestroyed()) {
            M();
            return;
        }
        v vVar = this.f35449b;
        vVar.s();
        if (iTrackInfo == null) {
            return;
        }
        if (this.f35462k == null) {
            this.f35462k = iTrackInfo;
        }
        if (this.f35462k.getBitrate() != iTrackInfo.getBitrate()) {
            int iP = f0.o().p(IjkPlayerRuntime.SP_LIVE_BITRATE, -100);
            if (iP != -100 && iP == iTrackInfo.getBitrate()) {
                runOnUiThread(new te.c(this, 1));
            }
            this.f35462k = iTrackInfo;
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            linkedHashMap.put("width", Integer.valueOf(this.f35462k.getWidth()));
            linkedHashMap.put("height", Integer.valueOf(this.f35462k.getHeight()));
            linkedHashMap.put("bandwidth", Integer.valueOf(this.f35462k.getBitrate()));
            linkedHashMap.put("frameRate", Integer.valueOf(this.f35462k.getFrameRate()));
            linkedHashMap.put("codecs", this.f35462k.getCodecs());
            xyz.netfly.api.c.b().l(linkedHashMap);
        }
        ((k) this.binding).f27108n.setText(iTrackInfo.getWidth() + "x" + iTrackInfo.getHeight() + " (" + iTrackInfo.getBitrate() + ")");
        try {
            ((k) this.binding).f27116v.setText(String.valueOf(vVar.k(iTrackInfo).getBitrate()));
        } catch (Exception e10) {
            u.a.g(e10, new StringBuilder("get next video track error: "));
        }
    }

    @Override // xyz.stream.view.BaseActivity
    public final void playReminderLive(Object obj) {
        super.playReminderLive(obj);
        LiveChannelEntity liveChannelEntity = obj instanceof LiveChannelEntity ? (LiveChannelEntity) obj : null;
        if (liveChannelEntity != null) {
            M();
            this.f35455e = liveChannelEntity;
            this.f35458g = false;
            xyz.netfly.api.c.b().c();
            initView();
        }
    }

    @Override // xe.b
    public final void q(LiveChannelEntity liveChannelEntity) {
        if (liveChannelEntity != null) {
            if (Objects.equals(liveChannelEntity.getId(), this.f35455e.getId()) && Objects.equals(liveChannelEntity.getCategoryId(), this.f35455e.getCategoryId())) {
                return;
            }
            a.u().getClass();
            if (a.t(liveChannelEntity) > 1) {
                y.a0(this);
                return;
            }
            M();
            LiveChannelEntity liveChannelEntity2 = this.f35455e;
            if (liveChannelEntity2 != null && this.f35453d != null) {
                l.a(liveChannelEntity2.getId().intValue(), y.l(this.f35453d.getTotalByte()), this.f35457f);
            }
            this.f35455e = liveChannelEntity;
            this.f35458g = false;
            xyz.netfly.api.c.b().c();
            initView();
        }
    }

    @Override // ag.c
    public final void u(String str) {
        ((k) this.binding).f27114t.setText(str);
    }

    @Override // ag.c
    public final void w() {
        long currentPosition = this.f35453d.getCurrentPosition();
        long bufferedPosition = this.f35453d.getBufferedPosition();
        ((k) this.binding).f27102h.setText(String.valueOf(currentPosition));
        ((k) this.binding).f27100f.setText(String.valueOf(bufferedPosition));
        TextView textView = ((k) this.binding).f27099e;
        StringBuilder sb = new StringBuilder();
        long j10 = bufferedPosition - currentPosition;
        sb.append(j10);
        sb.append("ms");
        textView.setText(sb.toString());
        ((k) this.binding).f27117w.setText(String.valueOf(((int) j10) / 3000));
        ((k) this.binding).f27107m.setText(f0.o().q(IjkPlayerRuntime.SP_HISTORY_BITRATE, SessionDescription.SUPPORTED_SDP_VERSION));
        ((k) this.binding).f27109o.setText(AbrController.getInstance().getsGlobalSelectBitrateStr());
    }

    @Override // ag.c
    public final void z() {
    }
}
