package xyz.netfly.player.playback;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import f.a;
import ie.x4;
import me.c;
import me.d;
import me.f;
import org.drive_hunter.R;
import tv.danmaku.ijk.media.player.ui.IjkVideoView;
import xyz.netfly.ads.h;
import xyz.netfly.player.playback.PlaybackSeekControl;
import xyz.stream.utils.e;
import xyz.stream.view.DefaultTimeBar;
import xyz.stream.view.UiUtils;
import xyz.stream.view.listener.SeekListener;
import xyz.stream.view.listener.TimeBar;

/* JADX INFO: loaded from: classes3.dex */
public class PlaybackSeekControl extends FrameLayout implements TimeBar.OnScrubListener {

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final x4 f35265h;

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

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

    public static void a(PlaybackSeekControl playbackSeekControl, View view, boolean z10) {
        int i10;
        playbackSeekControl.getClass();
        switch (view.getId()) {
            case R.id.play_audio /* 2131362705 */:
                i10 = !z10 ? R.mipmap.btn_audio_white : R.mipmap.audio_black;
                break;
            case R.id.play_center_btn /* 2131362706 */:
            case R.id.play_quality /* 2131362710 */:
            case R.id.play_second_title /* 2131362711 */:
            case R.id.play_setting /* 2131362713 */:
            case R.id.play_source /* 2131362715 */:
            case R.id.play_title /* 2131362718 */:
            default:
                i10 = 0;
                break;
            case R.id.play_control /* 2131362707 */:
                if (!z10) {
                    i10 = !playbackSeekControl.f35264g ? R.mipmap.live_play_white : R.mipmap.live_pause_white;
                } else if (!playbackSeekControl.f35264g) {
                    i10 = R.mipmap.live_play_black;
                } else {
                    i10 = R.mipmap.live_pause_black;
                }
                break;
            case R.id.play_feedback /* 2131362708 */:
                i10 = !z10 ? R.mipmap.play_feedback_white : R.mipmap.play_feedback_black;
                break;
            case R.id.play_next /* 2131362709 */:
                i10 = !z10 ? R.mipmap.btn_next_white : R.mipmap.btn_next_black;
                break;
            case R.id.play_series /* 2131362712 */:
                i10 = !z10 ? R.mipmap.btn_series_white : R.mipmap.btn_series_black;
                break;
            case R.id.play_setting_tv /* 2131362714 */:
                i10 = !z10 ? R.mipmap.mobile_settings : R.mipmap.player_settings_black;
                break;
            case R.id.play_speed /* 2131362716 */:
                i10 = !z10 ? R.mipmap.btn_speed_white : R.mipmap.btn_speed_black;
                break;
            case R.id.play_subtitle /* 2131362717 */:
                i10 = !z10 ? R.mipmap.btn_subtitle_white : R.mipmap.btn_subtitle_black;
                break;
            case R.id.play_video_ratio /* 2131362719 */:
                i10 = !z10 ? R.mipmap.ratio_white : R.mipmap.ratio_black;
                break;
        }
        f fVar = playbackSeekControl.f35266i;
        if (fVar != null) {
            c cVar = (c) fVar;
            if (z10) {
                cVar.c();
            }
        }
        if (i10 != 0) {
            ((ImageView) view).setImageDrawable(a.getDrawable(playbackSeekControl.getContext(), i10));
        }
    }

    public final void b() {
        IjkVideoView ijkVideoView = this.f35259b;
        if (ijkVideoView == null) {
            return;
        }
        long duration = ijkVideoView.getDuration();
        long currentPosition = this.f35259b.getCurrentPosition();
        long bufferedPosition = this.f35259b.getBufferedPosition();
        boolean z10 = currentPosition != this.f35261d;
        boolean z11 = duration != this.f35260c;
        this.f35260c = duration;
        this.f35261d = currentPosition;
        x4 x4Var = this.f35265h;
        if (z11) {
            x4Var.f27694n.setDuration(duration);
            x4Var.f27683c.setText(UiUtils.stringToTime(duration >= 0 ? duration : 0L));
        }
        if (z10 && !this.f35262e) {
            x4Var.f27694n.setPosition(currentPosition);
            x4Var.f27694n.setBufferedPosition(bufferedPosition);
            x4Var.f27683c.setText(String.format("%s / %s", UiUtils.stringToTime(currentPosition), UiUtils.stringToTime(duration)));
        }
        removeCallbacks(this.f35258a);
        if (this.f35259b.isPlaying()) {
            postDelayed(this.f35258a, Math.max(200L, Math.min((long) (Math.min(x4Var.f27694n.getPreferredUpdateDelay(), 1000 - (currentPosition % 1000)) / this.f35259b.getSpeed()), 1000L)));
        } else {
            postDelayed(this.f35258a, 1000L);
        }
    }

    public ConstraintLayout getBottomLayout() {
        return this.f35265h.f27682b;
    }

    public ImageView getBtnAudio() {
        return this.f35265h.f27685e;
    }

    public ImageView getBtnFeedback() {
        return this.f35265h.f27687g;
    }

    public ImageView getBtnPlay() {
        return this.f35265h.f27686f;
    }

    public TextView getBtnQuality() {
        return this.f35265h.f27688h;
    }

    public ImageView getBtnRatio() {
        return this.f35265h.f27693m;
    }

    public TextView getBtnSource() {
        return this.f35265h.f27690j;
    }

    public ImageView getBtnSpeed() {
        return this.f35265h.f27691k;
    }

    public ImageView getIvBack() {
        return this.f35265h.f27684d;
    }

    public TextView getSecondTitleView() {
        return this.f35265h.f27689i;
    }

    public DefaultTimeBar getTimeBar() {
        return this.f35265h.f27694n;
    }

    public TextView getTitleView() {
        return this.f35265h.f27692l;
    }

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

    @Override // xyz.stream.view.listener.TimeBar.OnScrubListener
    public final void onScrubMove(TimeBar timeBar, long j10) {
        this.f35265h.f27683c.setText(String.format("%s / %s", UiUtils.stringToTime(j10), UiUtils.stringToTime(this.f35260c)));
        SeekListener seekListener = this.f35263f;
        if (seekListener != null) {
            seekListener.onSeekMove(timeBar, j10);
        }
    }

    @Override // xyz.stream.view.listener.TimeBar.OnScrubListener
    public final void onScrubStart(TimeBar timeBar, long j10) {
        this.f35262e = true;
        this.f35265h.f27683c.setText(String.format("%s / %s", UiUtils.stringToTime(j10), UiUtils.stringToTime(this.f35260c)));
        SeekListener seekListener = this.f35263f;
        if (seekListener != null) {
            seekListener.onSeekStart(timeBar, j10);
        }
    }

    @Override // xyz.stream.view.listener.TimeBar.OnScrubListener
    public final void onScrubStop(TimeBar timeBar, long j10, boolean z10) {
        this.f35262e = false;
        if (!z10) {
            xyz.stream.utils.f.p().x("seekToTimeBarPosition: positionMs = " + j10);
            this.f35259b.seekTo(j10);
            b();
        }
        SeekListener seekListener = this.f35263f;
        if (seekListener != null) {
            seekListener.onSeekStop(timeBar, j10, z10);
        }
    }

    public void setControllerListener(f fVar) {
        this.f35266i = fVar;
    }

    public void setPlayButtonIcon(boolean z10) {
        this.f35264g = z10;
        if (z10) {
            getBtnPlay().setImageDrawable(a.getDrawable(getContext(), getBtnPlay().isFocused() ? R.mipmap.live_pause_black : R.mipmap.live_pause_white));
        } else {
            getBtnPlay().setImageDrawable(a.getDrawable(getContext(), getBtnPlay().isFocused() ? R.mipmap.live_play_black : R.mipmap.live_play_white));
        }
    }

    public void setSeekListener(SeekListener seekListener) {
        this.f35263f = seekListener;
    }

    public void setVideoView(IjkVideoView ijkVideoView) {
        this.f35259b = ijkVideoView;
        this.f35265h.f27683c.setText(String.format("%s / %s", UiUtils.stringToTime(0L), UiUtils.stringToTime(0L)));
    }

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

    public PlaybackSeekControl(Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        final int i11 = 0;
        x4 x4VarInflate = x4.inflate(LayoutInflater.from(context), null, false);
        this.f35265h = x4VarInflate;
        addView(x4VarInflate.f27681a);
        getBtnRatio().setImageDrawable(a.getDrawable(getContext(), R.mipmap.ratio_white));
        getBtnSpeed().setImageDrawable(a.getDrawable(getContext(), R.mipmap.btn_speed_white));
        getBtnFeedback().setImageDrawable(a.getDrawable(getContext(), R.mipmap.play_feedback_white));
        getBtnAudio().setImageDrawable(a.getDrawable(getContext(), R.mipmap.btn_audio_white));
        this.f35258a = new h(this, 11);
        DefaultTimeBar defaultTimeBar = x4VarInflate.f27694n;
        defaultTimeBar.setKeyTimeIncrement(10000L);
        getTimeBar().setOnKeyListener(new d(0));
        getTimeBar().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: me.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ PlaybackSeekControl f30671b;

            {
                this.f30671b = this;
            }

            @Override // android.view.View.OnFocusChangeListener
            public final void onFocusChange(View view, boolean z10) {
                int i12 = i11;
                PlaybackSeekControl playbackSeekControl = this.f30671b;
                switch (i12) {
                    case 0:
                        f fVar = playbackSeekControl.f35266i;
                        if (fVar != null) {
                            c cVar = (c) fVar;
                            if (z10) {
                                cVar.c();
                            }
                        }
                        break;
                    case 1:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 2:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 3:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 4:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    default:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                }
            }
        });
        final int i12 = 1;
        getBtnPlay().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: me.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ PlaybackSeekControl f30671b;

            {
                this.f30671b = this;
            }

            @Override // android.view.View.OnFocusChangeListener
            public final void onFocusChange(View view, boolean z10) {
                int i122 = i12;
                PlaybackSeekControl playbackSeekControl = this.f30671b;
                switch (i122) {
                    case 0:
                        f fVar = playbackSeekControl.f35266i;
                        if (fVar != null) {
                            c cVar = (c) fVar;
                            if (z10) {
                                cVar.c();
                            }
                        }
                        break;
                    case 1:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 2:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 3:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 4:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    default:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                }
            }
        });
        final int i13 = 2;
        getBtnAudio().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: me.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ PlaybackSeekControl f30671b;

            {
                this.f30671b = this;
            }

            @Override // android.view.View.OnFocusChangeListener
            public final void onFocusChange(View view, boolean z10) {
                int i122 = i13;
                PlaybackSeekControl playbackSeekControl = this.f30671b;
                switch (i122) {
                    case 0:
                        f fVar = playbackSeekControl.f35266i;
                        if (fVar != null) {
                            c cVar = (c) fVar;
                            if (z10) {
                                cVar.c();
                            }
                        }
                        break;
                    case 1:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 2:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 3:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 4:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    default:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                }
            }
        });
        final int i14 = 3;
        getBtnSpeed().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: me.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ PlaybackSeekControl f30671b;

            {
                this.f30671b = this;
            }

            @Override // android.view.View.OnFocusChangeListener
            public final void onFocusChange(View view, boolean z10) {
                int i122 = i14;
                PlaybackSeekControl playbackSeekControl = this.f30671b;
                switch (i122) {
                    case 0:
                        f fVar = playbackSeekControl.f35266i;
                        if (fVar != null) {
                            c cVar = (c) fVar;
                            if (z10) {
                                cVar.c();
                            }
                        }
                        break;
                    case 1:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 2:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 3:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 4:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    default:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                }
            }
        });
        final int i15 = 4;
        getBtnFeedback().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: me.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ PlaybackSeekControl f30671b;

            {
                this.f30671b = this;
            }

            @Override // android.view.View.OnFocusChangeListener
            public final void onFocusChange(View view, boolean z10) {
                int i122 = i15;
                PlaybackSeekControl playbackSeekControl = this.f30671b;
                switch (i122) {
                    case 0:
                        f fVar = playbackSeekControl.f35266i;
                        if (fVar != null) {
                            c cVar = (c) fVar;
                            if (z10) {
                                cVar.c();
                            }
                        }
                        break;
                    case 1:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 2:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 3:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 4:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    default:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                }
            }
        });
        final int i16 = 5;
        getBtnRatio().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: me.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ PlaybackSeekControl f30671b;

            {
                this.f30671b = this;
            }

            @Override // android.view.View.OnFocusChangeListener
            public final void onFocusChange(View view, boolean z10) {
                int i122 = i16;
                PlaybackSeekControl playbackSeekControl = this.f30671b;
                switch (i122) {
                    case 0:
                        f fVar = playbackSeekControl.f35266i;
                        if (fVar != null) {
                            c cVar = (c) fVar;
                            if (z10) {
                                cVar.c();
                            }
                        }
                        break;
                    case 1:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 2:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 3:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    case 4:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                    default:
                        PlaybackSeekControl.a(playbackSeekControl, view, z10);
                        break;
                }
            }
        });
        if (e.d().f36119h || e.d().f36121j) {
            UiUtils.setUnFocusable(defaultTimeBar);
            UiUtils.setUnFocusable(x4VarInflate.f27690j);
            UiUtils.setUnFocusable(x4VarInflate.f27686f);
            UiUtils.setUnFocusable(x4VarInflate.f27687g);
            UiUtils.setUnFocusable(x4VarInflate.f27688h);
            UiUtils.setUnFocusable(x4VarInflate.f27691k);
            UiUtils.setUnFocusable(x4VarInflate.f27693m);
        }
        defaultTimeBar.addListener(this);
        removeCallbacks(this.f35258a);
        post(this.f35258a);
    }
}
