package d3;

import android.content.Context;
import android.os.SystemClock;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.State;
import androidx.media3.common.Player;
import androidx.media3.exoplayer.ExoPlayer;
import com.debridstream.tv.PlayerViewModel;
import java.util.concurrent.atomic.AtomicBoolean;
import okhttp3.OkHttpClient;

/* JADX INFO: renamed from: d3.z1, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1944z1 implements Player.Listener {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ AtomicBoolean f16201a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ MutableState f16203c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ MutableState f16204d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ MutableState f16205e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ MutableState f16206f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ MutableState f16207j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ AtomicBoolean f16208k;
    public final /* synthetic */ V4.C l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ Context f16209m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ PlayerViewModel f16210n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final /* synthetic */ J4.a f16211o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final /* synthetic */ State f16212p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ State f16213q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ MutableState f16214r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ N2.r f16215s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final /* synthetic */ OkHttpClient f16216t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final /* synthetic */ State f16217u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final /* synthetic */ State f16218v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final /* synthetic */ State f16219w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final /* synthetic */ State f16220x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final /* synthetic */ State f16221y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final /* synthetic */ State f16222z;

    public C1944z1(J4.a aVar, N2.r rVar, V4.C c6, Context context, MutableState mutableState, MutableState mutableState2, MutableState mutableState3, MutableState mutableState4, MutableState mutableState5, MutableState mutableState6, State state, State state2, State state3, State state4, State state5, State state6, State state7, State state8, ExoPlayer exoPlayer, PlayerViewModel playerViewModel, AtomicBoolean atomicBoolean, AtomicBoolean atomicBoolean2, OkHttpClient okHttpClient) {
        this.f16201a = atomicBoolean;
        this.f16202b = exoPlayer;
        this.f16203c = mutableState;
        this.f16204d = mutableState2;
        this.f16205e = mutableState3;
        this.f16206f = mutableState4;
        this.f16207j = mutableState5;
        this.f16208k = atomicBoolean2;
        this.l = c6;
        this.f16209m = context;
        this.f16210n = playerViewModel;
        this.f16211o = aVar;
        this.f16212p = state;
        this.f16213q = state2;
        this.f16214r = mutableState6;
        this.f16215s = rVar;
        this.f16216t = okHttpClient;
        this.f16217u = state3;
        this.f16218v = state4;
        this.f16219w = state5;
        this.f16220x = state6;
        this.f16221y = state7;
        this.f16222z = state8;
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // androidx.media3.common.Player.Listener
    public final void onPlayWhenReadyChanged(boolean z6, int i6) {
        AtomicBoolean atomicBoolean = this.f16201a;
        boolean z7 = atomicBoolean.get();
        MutableState mutableState = this.f16203c;
        if (!z7) {
            MutableState mutableState2 = this.f16205e;
            if (z6) {
                v2.B(mutableState2, true);
                Long l = (Long) mutableState.getValue();
                mutableState.setValue(null);
                if (l != null) {
                    if (SystemClock.elapsedRealtime() - l.longValue() > 5000) {
                        ExoPlayer exoPlayer = this.f16202b;
                        long currentPosition = exoPlayer.getCurrentPosition() - 6000;
                        if (currentPosition < 0) {
                            currentPosition = 0;
                        }
                        exoPlayer.seekTo(currentPosition);
                    }
                }
            } else {
                mutableState.setValue(Long.valueOf(SystemClock.elapsedRealtime()));
                v2.A(this.f16204d, true);
                v2.B(mutableState2, false);
            }
        } else if (z6) {
            mutableState.setValue(null);
        }
        if (atomicBoolean.get()) {
            return;
        }
        this.f16206f.setValue(Boolean.valueOf(z6));
    }

    @Override // androidx.media3.common.Player.Listener
    public final void onPlaybackStateChanged(int i6) {
        this.f16207j.setValue(Integer.valueOf(i6));
        if (i6 == 4) {
            v2.b0(this.f16208k, this.l, this.f16209m, this.f16210n, this.f16202b, this.f16211o, this.f16212p, this.f16213q, this.f16214r, this.f16215s, this.f16216t, this.f16217u, this.f16218v, this.f16219w, this.f16220x, this.f16221y, this.f16222z, "playback_state_ended", true, true);
        }
    }
}
