package xyz.netfly.mobile.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
import ie.h5;
import tv.danmaku.ijk.media.player.ui.BasePlayerView;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes3.dex */
public class VideoDetailFullControl extends FrameLayout implements SeekBar.OnSeekBarChangeListener {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final /* synthetic */ int f35137g = 0;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final h5 f35138a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final xyz.netfly.ads.h f35139b;

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f35143f;

    public VideoDetailFullControl(Context context) {
        this(context, null);
    }

    public final void a() {
        BasePlayerView basePlayerView = this.f35140c;
        if (basePlayerView == null) {
            return;
        }
        long duration = basePlayerView.getDuration();
        long currentPosition = this.f35140c.getCurrentPosition();
        long bufferedPosition = this.f35140c.getBufferedPosition();
        boolean z10 = currentPosition != this.f35142e;
        boolean z11 = duration != this.f35141d;
        this.f35141d = duration;
        this.f35142e = currentPosition;
        h5 h5Var = this.f35138a;
        if (z11) {
            h5Var.f26967d.setText(UiUtils.stringToTime(duration < 0 ? 0L : duration));
        }
        int i10 = duration == 0 ? 0 : (int) ((bufferedPosition * 100) / duration);
        if (z10 && !this.f35143f) {
            SeekBar seekBar = h5Var.f26982s;
            seekBar.setProgress((int) ((((long) seekBar.getMax()) * currentPosition) / duration));
            SeekBar seekBar2 = h5Var.f26982s;
            if (i10 >= 95) {
                seekBar2.setSecondaryProgress(seekBar2.getMax());
            } else {
                seekBar2.setSecondaryProgress(i10 * 10);
            }
            h5Var.f26967d.setText(String.format("%s / %s", UiUtils.stringToTime(currentPosition), UiUtils.stringToTime(duration)));
        }
        if (this.f35142e < C.DEFAULT_SEEK_FORWARD_INCREMENT_MS) {
            h5Var.f26981r.setEnabled(false);
            h5Var.f26981r.setAlpha(0.5f);
        } else {
            h5Var.f26981r.setEnabled(true);
            h5Var.f26981r.setAlpha(1.0f);
        }
        if (this.f35142e > duration - C.DEFAULT_SEEK_FORWARD_INCREMENT_MS) {
            h5Var.f26978o.setEnabled(false);
            h5Var.f26978o.setAlpha(0.5f);
        } else {
            h5Var.f26978o.setEnabled(true);
            h5Var.f26978o.setAlpha(1.0f);
        }
        removeCallbacks(this.f35139b);
        if (this.f35140c.isPlaying()) {
            postDelayed(this.f35139b, Math.max(200L, Math.min((long) ((1000 - (currentPosition % 1000)) / this.f35140c.getSpeed()), 1000L)));
        } else {
            postDelayed(this.f35139b, 1000L);
        }
    }

    public ImageView getBtnAirplay() {
        return this.f35138a.f26965b;
    }

    public ImageView getBtnBack() {
        return this.f35138a.f26966c;
    }

    public ImageView getBtnFeed() {
        return this.f35138a.f26968e;
    }

    public ImageView getBtnNext() {
        return this.f35138a.f26978o;
    }

    public ImageView getBtnPip() {
        return this.f35138a.f26970g;
    }

    public ImageView getBtnPlay() {
        return this.f35138a.f26979p;
    }

    public ImageView getBtnPre() {
        return this.f35138a.f26981r;
    }

    public LinearLayout getBtnQuality() {
        return this.f35138a.f26974k;
    }

    public LinearLayout getEpisode() {
        return this.f35138a.f26972i;
    }

    public ImageView getLock() {
        return this.f35138a.f26969f;
    }

    public LinearLayout getNext() {
        return this.f35138a.f26973j;
    }

    public TextView getQualityText() {
        return this.f35138a.f26987x;
    }

    public SeekBar getSeekBar() {
        return this.f35138a.f26982s;
    }

    public ImageView getSetting() {
        return this.f35138a.f26971h;
    }

    public LinearLayout getSpeed() {
        return this.f35138a.f26975l;
    }

    public TextView getSpeedText() {
        return this.f35138a.f26989z;
    }

    public LinearLayout getSubtitle() {
        return this.f35138a.f26976m;
    }

    public TextView getSubtitleProgressView() {
        return this.f35138a.f26983t;
    }

    public TextView getTitle() {
        return this.f35138a.f26984u;
    }

    public LinearLayout getVideoRatio() {
        return this.f35138a.f26977n;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        removeCallbacks(this.f35139b);
    }

    @Override // android.widget.SeekBar.OnSeekBarChangeListener
    public final void onProgressChanged(SeekBar seekBar, int i10, boolean z10) {
        if (z10) {
            this.f35138a.f26967d.setText(String.format("%s / %s", UiUtils.stringToTime((((long) this.f35140c.getDuration()) * ((long) i10)) / ((long) seekBar.getMax())), UiUtils.stringToTime(this.f35141d)));
        }
    }

    @Override // android.widget.SeekBar.OnSeekBarChangeListener
    public final void onStartTrackingTouch(SeekBar seekBar) {
        this.f35143f = true;
    }

    @Override // android.widget.SeekBar.OnSeekBarChangeListener
    public final void onStopTrackingTouch(SeekBar seekBar) {
        long duration = (((long) this.f35140c.getDuration()) * ((long) seekBar.getProgress())) / ((long) seekBar.getMax());
        this.f35143f = false;
        xyz.netfly.api.c.b().o();
        this.f35140c.seekTo(duration);
        a();
    }

    public void setEpisodeText(String str) {
        this.f35138a.f26985v.setText(str);
    }

    public void setNextText(String str) {
        this.f35138a.f26986w.setText(str);
    }

    public void setRatioText(String str) {
        this.f35138a.f26988y.setText(str);
    }

    public void setSpeedText(String str) {
        this.f35138a.f26989z.setText(str);
    }

    public void setSubtitleText(String str) {
        this.f35138a.A.setText(str);
    }

    public void setVideoView(BasePlayerView basePlayerView) {
        this.f35140c = basePlayerView;
        this.f35138a.f26967d.setText(String.format("%s / %s", UiUtils.stringToTime(0L), UiUtils.stringToTime(0L)));
    }

    public VideoDetailFullControl(Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public VideoDetailFullControl(Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        h5 h5VarInflate = h5.inflate(LayoutInflater.from(context), this, true);
        this.f35138a = h5VarInflate;
        this.f35139b = new xyz.netfly.ads.h(this, 8);
        h5VarInflate.f26982s.setOnSeekBarChangeListener(this);
        removeCallbacks(this.f35139b);
        post(this.f35139b);
    }
}
