package com.strmr.ps.ui.player;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.RenderEffect;
import android.graphics.Shader;
import android.hardware.display.DisplayManager;
import android.media.AudioDeviceInfo;
import android.media.AudioFocusRequest;
import android.media.AudioManager;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.audiofx.LoudnessEnhancer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.util.Property;
import android.view.Display;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.cardview.widget.CardView;
import androidx.credentials.exceptions.publickeycredential.DomExceptionUtils;
import androidx.lifecycle.s;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.C;
import androidx.media3.common.Format;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.PlaybackParameters;
import androidx.media3.common.Player;
import androidx.media3.common.TrackSelectionOverride;
import androidx.media3.common.TrackSelectionParameters;
import androidx.media3.common.Tracks;
import androidx.media3.common.text.Cue;
import androidx.media3.common.text.CueGroup;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.datasource.DefaultDataSource;
import androidx.media3.datasource.okhttp.OkHttpDataSource;
import androidx.media3.exoplayer.DefaultLoadControl;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.dash.DashMediaSource;
import androidx.media3.exoplayer.hls.HlsMediaSource;
import androidx.media3.exoplayer.rtsp.RtpPayloadFormat;
import androidx.media3.exoplayer.rtsp.RtspHeaders;
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory;
import androidx.media3.exoplayer.source.MediaSource;
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
import androidx.media3.exoplayer.trackselection.TrackSelector;
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
import androidx.media3.exoplayer.upstream.CmcdData;
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
import androidx.media3.exoplayer.video.VideoFrameMetadataListener;
import androidx.media3.extractor.DefaultExtractorsFactory;
import androidx.media3.extractor.text.ttml.TtmlNode;
import androidx.media3.session.MediaSession;
import androidx.media3.ui.CaptionStyleCompat;
import androidx.media3.ui.PlayerView;
import androidx.media3.ui.SubtitleView;
import androidx.recyclerview.widget.RecyclerView;
import com.strmr.ps.R;
import com.strmr.ps.StrmrApp;
import com.strmr.ps.data.event.PlaybackStateManager;
import com.strmr.ps.data.local.entity.PlaybackProgress;
import com.strmr.ps.data.local.entity.PlayerSettings;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.model.StreamInfo;
import com.strmr.ps.data.model.tmdb.TMDBEpisode;
import com.strmr.ps.data.model.tmdb.TMDBSeasonDetails;
import com.strmr.ps.data.remote.api.TMDBApiService;
import com.strmr.ps.data.repository.PlaybackProgressRepository;
import com.strmr.ps.data.repository.PlayerSettingsRepository;
import com.strmr.ps.data.repository.PreferencesRepository;
import com.strmr.ps.data.repository.SkipInterval;
import com.strmr.ps.data.repository.SkipIntroRepository;
import com.strmr.ps.data.repository.TraktScrobbleRepository;
import com.strmr.ps.data.repository.TraktSyncRepository;
import com.strmr.ps.data.service.AddonResolutionService;
import com.strmr.ps.data.subtitle.SubtitleManager;
import com.strmr.ps.data.subtitle.t;
import com.strmr.ps.service.PlaybackService;
import com.strmr.ps.ui.player.VideoPlayerActivity;
import com.strmr.ps.ui.player.h;
import com.strmr.ps.ui.sources.SourcesActivity;
import dagger.hilt.android.AndroidEntryPoint;
import defpackage.a18;
import defpackage.ak2;
import defpackage.bj4;
import defpackage.bk1;
import defpackage.cba;
import defpackage.cha;
import defpackage.cia;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.dw7;
import defpackage.e17;
import defpackage.e62;
import defpackage.e6a;
import defpackage.eha;
import defpackage.fh2;
import defpackage.fha;
import defpackage.fi7;
import defpackage.fx4;
import defpackage.gha;
import defpackage.gv3;
import defpackage.h48;
import defpackage.hf5;
import defpackage.hha;
import defpackage.hn2;
import defpackage.hx9;
import defpackage.iha;
import defpackage.ik2;
import defpackage.io6;
import defpackage.iw7;
import defpackage.jha;
import defpackage.jk2;
import defpackage.jn2;
import defpackage.kha;
import defpackage.kq;
import defpackage.kx;
import defpackage.ky8;
import defpackage.l08;
import defpackage.lx;
import defpackage.m02;
import defpackage.m12;
import defpackage.mha;
import defpackage.mr8;
import defpackage.n41;
import defpackage.n89;
import defpackage.o74;
import defpackage.oha;
import defpackage.pha;
import defpackage.pw7;
import defpackage.q07;
import defpackage.qha;
import defpackage.ql9;
import defpackage.rha;
import defpackage.rx4;
import defpackage.s38;
import defpackage.sb9;
import defpackage.sc2;
import defpackage.sf1;
import defpackage.sga;
import defpackage.sm5;
import defpackage.st;
import defpackage.t7a;
import defpackage.uga;
import defpackage.va;
import defpackage.vga;
import defpackage.vw2;
import defpackage.vx8;
import defpackage.w18;
import defpackage.wf4;
import defpackage.wj0;
import defpackage.wo5;
import defpackage.wt0;
import defpackage.x3;
import defpackage.y41;
import defpackage.zr7;
import fi.iki.elonen.NanoHTTPD;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0007\u0018\u00002\u00020\u0001:\u0004\u0004\u0005\u0006\u0007B\u0007¢\u0006\u0004\b\u0002\u0010\u0003¨\u0006\b"}, d2 = {"Lcom/strmr/ps/ui/player/VideoPlayerActivity;", "Landroidx/fragment/app/t;", "<init>", "()V", "b", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "d", "c", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@AndroidEntryPoint
@vx8
public final class VideoPlayerActivity extends o74 {
    public static final long[] R0 = {10000, 30000, 60000, 120000, 180000};
    public static final float[] S0 = {0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 2.0f};
    public static final String[] T0 = {"0.5x", "0.75x", "1x (Normal)", "1.25x", "1.5x", "2x"};
    public static final List U0 = y41.an(new q07(PlayerSettings.SUBTITLE_FONT_DEFAULT, "Default (Bold)"), new q07(PlayerSettings.SUBTITLE_FONT_SANS_SERIF, "Sans-Serif"), new q07(PlayerSettings.SUBTITLE_FONT_SANS_SERIF_LIGHT, "Sans-Serif Light"), new q07("serif", "Serif"), new q07(PlayerSettings.SUBTITLE_FONT_MONOSPACE, "Monospace"), new q07(PlayerSettings.SUBTITLE_FONT_CASUAL, "Casual"), new q07(PlayerSettings.SUBTITLE_FONT_INTER_REGULAR, "Inter Regular"), new q07(PlayerSettings.SUBTITLE_FONT_INTER_MEDIUM, "Inter Medium"));
    public fx4 A;
    public boolean A0;
    public long B;
    public int B0;
    public final sga C;
    public boolean C0;
    public boolean D;
    public int D0;
    public final sga E;
    public final int E0;
    public FrameLayout F;
    public boolean F0;
    public Button G;
    public boolean G0;
    public ProgressBar H;
    public boolean H0;
    public List I;
    public boolean I0;
    public SkipInterval J;
    public long J0;
    public fx4 K;
    public int K0;
    public fx4 L;
    public OkHttpClient L0;
    public boolean M;
    public DefaultDataSource.Factory M0;
    public boolean N;
    public OkHttpDataSource.Factory N0;
    public fx4 O;
    public final Object O0;
    public boolean P;
    public final Set P0;
    public boolean Q;
    public h Q0;
    public final long R;
    public List S;
    public com.strmr.ps.data.subtitle.t T;
    public fx4 U;
    public boolean V;
    public int W;
    public int X;
    public FrameLayout Y;
    public com.strmr.ps.ui.player.a Z;
    public long a0;
    public TextView aa;
    public ImageView ab;
    public View ac;
    public LinearLayout ad;
    public LinearLayout ae;
    public TextView af;
    public TextView ag;
    public TextView ah;
    public TextView ai;
    public TextView aj;
    public SeekBar ak;
    public ImageButton al;
    public ImageButton am;
    public ImageButton an;
    public ImageButton ao;
    public ImageButton ap;
    public ImageButton aq;
    public ImageButton ar;
    public ImageButton as;
    public ImageButton at;
    public TextView au;
    public LinearLayout av;
    public ImageButton aw;
    public ImageButton ax;
    public ImageButton ay;
    public boolean az;
    public long b0;
    public FrameLayout ba;
    public ImageView bb;
    public TextView bc;
    public CardView bf;
    public ImageView bg;
    public TextView bh;
    public TextView bi;
    public TextView bj;
    public Button bk;
    public Button bl;
    public ExoPlayer bm;
    public MediaSession bn;
    public DefaultMediaSourceFactory bp;
    public MediaSource bq;
    public MediaSource br;
    public String bu;
    public Map bv;
    public ContentItem bw;
    public final kx c0;
    public long ca;
    public boolean cb;
    public boolean cc;
    public List ce;
    public int cf;
    public int cg;
    public final LinkedHashSet ch;
    public String ci;
    public boolean cj;
    public boolean ck;
    public volatile String cl;
    public boolean cm;
    public long cn;
    public long co;
    public boolean cp;
    public final Handler cq;
    public AnimatorSet cr;
    public boolean cs;
    public fx4 ct;
    public int cu;
    public boolean cv;
    public pha cw;
    public float cx;
    public fx4 cy;
    public boolean cz;
    public final wt0 d0;
    public final fh2 e0;
    public PlayerSettingsRepository f;
    public boolean f0;
    public c g0;
    public AudioManager h0;
    public PreferencesRepository i;
    public AudioFocusRequest i0;
    public TraktScrobbleRepository j;
    public boolean j0;
    public SubtitleManager k;
    public boolean k0;
    public PlaybackProgressRepository l;
    public oha l0;
    public PlaybackStateManager m;
    public LoudnessEnhancer m0;
    public TMDBApiService n;
    public int n0;
    public TraktSyncRepository o;
    public d o0;
    public SkipIntroRepository p;
    public boolean p0;
    public AddonResolutionService q;
    public boolean q0;
    public PlayerView r;
    public boolean r0;
    public SubtitleView s;
    public fx4 s0;
    public FrameLayout t;
    public int t0;
    public ImageView u;
    public boolean u0;
    public ImageView v;
    public boolean v0;
    public TextView w;
    public GestureDetector w0;
    public ImageView x;
    public final lx x0;
    public FrameLayout y;
    public final LinkedHashSet y0;
    public TextView z;
    public boolean z0;
    public a bd = a.a;
    public float be = 1.0f;
    public PlayerSettings bo = PlayerSettings.INSTANCE.m55default();
    public String bs = "";
    public String bt = "";
    public int bx = -1;
    public int bz = -1;
    public double cd = -1.0d;

    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0000\b\u0086\u0081\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001¨\u0006\u0002"}, d2 = {"Lcom/strmr/ps/ui/player/VideoPlayerActivity$a;", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
        public static final a a;
        public static final a b;
        public static final a c;
        public static final /* synthetic */ a[] d;
        public static final /* synthetic */ hn2 e;

        static {
            a aVar = new a("FIT", 0);
            a = aVar;
            a aVar2 = new a("CROP", 1);
            b = aVar2;
            a aVar3 = new a("STRETCH", 2);
            c = aVar3;
            a[] aVarArr = {aVar, aVar2, aVar3};
            d = aVarArr;
            e = jn2.a(aVarArr);
        }

        public static a valueOf(String str) {
            return (a) Enum.valueOf(a.class, str);
        }

        public static a[] values() {
            return (a[]) d.clone();
        }
    }

    @Metadata(d1 = {"\u0000L\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u000b\n\u0002\u0010\t\n\u0002\b\u0005\n\u0002\u0010\b\n\u0002\b\u0006\n\u0002\u0010\u0007\n\u0002\b\u0003\n\u0002\u0010\u0016\n\u0002\b\u0005\n\u0002\u0010\u0014\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\f\b\u0086\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004R\u0014\u0010\u0005\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0005\u0010\u0004R\u0014\u0010\u0006\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0006\u0010\u0004R\u0014\u0010\u0007\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0007\u0010\u0004R\u0014\u0010\b\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\b\u0010\u0004R\u0014\u0010\t\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\t\u0010\u0004R\u0014\u0010\n\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\n\u0010\u0004R\u0014\u0010\u000b\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u000b\u0010\u0004R\u0014\u0010\f\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\f\u0010\u0004R\u0014\u0010\r\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\r\u0010\u0004R\u0014\u0010\u000f\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u000f\u0010\u0010R\u0014\u0010\u0011\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0011\u0010\u0010R\u0014\u0010\u0012\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0012\u0010\u0010R\u0014\u0010\u0013\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0013\u0010\u0010R\u0014\u0010\u0015\u001a\u00020\u00148\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0015\u0010\u0016R\u0014\u0010\u0017\u001a\u00020\u00148\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0017\u0010\u0016R\u0014\u0010\u0018\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0018\u0010\u0010R\u0014\u0010\u0019\u001a\u00020\u00148\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0019\u0010\u0016R\u0014\u0010\u001a\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u001a\u0010\u0010R\u0014\u0010\u001c\u001a\u00020\u001b8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u001c\u0010\u001dR\u0014\u0010\u001e\u001a\u00020\u00148\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u001e\u0010\u0016R\u0014\u0010 \u001a\u00020\u001f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b \u0010!R\u0014\u0010\"\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\"\u0010\u0010R\u0014\u0010#\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b#\u0010\u0010R\u0014\u0010$\u001a\u00020\u000e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b$\u0010\u0010R\u0014\u0010&\u001a\u00020%8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b&\u0010'R\u001a\u0010)\u001a\b\u0012\u0004\u0012\u00020\u00020(8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b)\u0010*R&\u0010-\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u0002\u0012\u0004\u0012\u00020\u00020,0+8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b-\u0010.R\u0014\u0010/\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b/\u0010\u0004R\u0014\u00100\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b0\u0010\u0004R\u0014\u00101\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b1\u0010\u0004R\u0014\u00102\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b2\u0010\u0004R\u0014\u00103\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b3\u0010\u0004R\u0014\u00104\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b4\u0010\u0004R\u0014\u00105\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b5\u0010\u0004R\u0014\u00106\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b6\u0010\u0004R\u0014\u00107\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b7\u0010\u0004¨\u00068"}, d2 = {"Lcom/strmr/ps/ui/player/VideoPlayerActivity$b;", "", "", "EXTRA_VIDEO_URL", "Ljava/lang/String;", "EXTRA_TITLE", "EXTRA_LOGO_URL", "EXTRA_CONTENT_ITEM", "EXTRA_SEASON", "EXTRA_EPISODE", "EXTRA_RESUME_POSITION_MS", "EXTRA_SOURCES_JSON", "EXTRA_CURRENT_SOURCE_INDEX", "EXTRA_PROXY_HEADERS", "", "LOGO_FADE_DURATION", "J", "LOGO_DISPLAY_DURATION", "CONTROLS_HIDE_DELAY", "PROGRESS_UPDATE_INTERVAL", "", "DB_SAVE_INTERVAL_TICKS", "I", "STUCK_PLAYBACK_THRESHOLD_TICKS", "POSITION_JUMP_THRESHOLD_MS", "MAX_AUTO_SWITCH_ATTEMPTS", "PLACEHOLDER_VIDEO_THRESHOLD_MS", "", "MIN_VALID_FRAME_RATE", "F", "MAX_PARSER_RECOVERY_ATTEMPTS", "", "PARSER_SKIP_FORWARD_STEPS_MS", "[J", "LINK_TTL_MS", "MIN_DURATION_FOR_NEXT_POPUP_MS", "MIN_PLAYBACK_FOR_NEXT_POPUP_MS", "", "SPEED_OPTIONS", "[F", "", "SPEED_LABELS", "[Ljava/lang/String;", "", "Lq07;", "SUBTITLE_FONT_PICKER_OPTIONS", "Ljava/util/List;", "KEY_VIDEO_URL", "KEY_TITLE", "KEY_LOGO_URL", "KEY_CONTENT_ITEM", "KEY_SEASON", "KEY_EPISODE", "KEY_POSITION_MS", "KEY_SUBTITLE_DELAY_MS", "KEY_HAS_RESUMED", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @vx8
    public static final class b {
        public static void a(Context context, String str, String str2, String str3, ContentItem contentItem, int i, int i2, long j, Map map) {
            cr4.g(str, "videoUrl");
            cr4.g(str2, "title");
            Intent intent = new Intent(context, (Class<?>) VideoPlayerActivity.class);
            intent.putExtra("video_url", str);
            intent.putExtra("title", str2);
            intent.putExtra("logo_url", str3);
            intent.putExtra("content_item", contentItem);
            intent.putExtra("season", i);
            intent.putExtra(PlaybackProgress.TYPE_EPISODE, i2);
            intent.putExtra("resume_position_ms", j);
            if (map != null) {
                intent.putExtra("proxy_headers", new HashMap(map));
            }
            context.startActivity(intent);
        }
    }

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\u0082\u0004\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lcom/strmr/ps/ui/player/VideoPlayerActivity$c;", "Landroidx/media3/common/Player$Listener;", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @vx8
    public final class c implements Player.Listener {
        public final SubtitleView a;
        public final Handler b;
        public final ArrayList c;
        public final /* synthetic */ VideoPlayerActivity d;

        public c(VideoPlayerActivity videoPlayerActivity, SubtitleView subtitleView) {
            cr4.g(subtitleView, "subtitleView");
            this.d = videoPlayerActivity;
            this.a = subtitleView;
            this.b = new Handler(Looper.getMainLooper());
            this.c = new ArrayList();
        }

        public final void a() {
            synchronized (this.c) {
                try {
                    Iterator it = this.c.iterator();
                    while (it.hasNext()) {
                        this.b.removeCallbacks((Runnable) it.next());
                    }
                    this.c.clear();
                } catch (Throwable th) {
                    throw th;
                }
            }
            this.a.setCues(ik2.a);
        }

        @Override // androidx.media3.common.Player.Listener
        public final void onCues(CueGroup cueGroup) {
            cr4.g(cueGroup, "cueGroup");
            bj4<Cue> bj4Var = cueGroup.cues;
            cr4.f(bj4Var, "cues");
            final ArrayList arrayList = new ArrayList(y41.p(bj4Var, 10));
            for (Cue cueBuild : bj4Var) {
                if (cueBuild.bitmap == null) {
                    cueBuild = cueBuild.buildUpon().setLine(-3.4028235E38f, 0).setPosition(-3.4028235E38f).setSize(-3.4028235E38f).setTextSize(-3.4028235E38f, 0).build();
                    cr4.f(cueBuild, "build(...)");
                }
                arrayList.add(cueBuild);
            }
            VideoPlayerActivity videoPlayerActivity = this.d;
            long j = videoPlayerActivity.a0;
            if (videoPlayerActivity.f0) {
                arrayList.size();
                this.a.setCues(arrayList);
                return;
            }
            arrayList.size();
            if (j <= 0) {
                this.a.setCues(arrayList);
                return;
            }
            final dw7.h hVar = new dw7.h();
            Runnable runnable = new Runnable() { // from class: com.strmr.ps.ui.player.l
                @Override // java.lang.Runnable
                public final void run() {
                    VideoPlayerActivity.c cVar = this.a;
                    ArrayList arrayList2 = arrayList;
                    dw7.h hVar2 = hVar;
                    cVar.a.setCues(arrayList2);
                    Runnable runnable2 = (Runnable) hVar2.a;
                    if (runnable2 != null) {
                        synchronized (cVar.c) {
                            cVar.c.remove(runnable2);
                        }
                    }
                }
            };
            hVar.a = runnable;
            synchronized (this.c) {
                this.c.add(runnable);
            }
            this.b.postDelayed(runnable, j);
        }

        @Override // androidx.media3.common.Player.Listener
        public final void onPositionDiscontinuity(Player.PositionInfo positionInfo, Player.PositionInfo positionInfo2, int i) {
            cr4.g(positionInfo, "oldPosition");
            cr4.g(positionInfo2, "newPosition");
            if (i == 1 || i == 2) {
                a();
            }
        }
    }

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0086\b\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lcom/strmr/ps/ui/player/VideoPlayerActivity$d;", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final /* data */ class d {
        public final int a;
        public final int b;
        public final int c;
        public final String d;
        public final String e;
        public final Long f;

        public d(int i, int i2, int i3, String str, String str2, Long l) {
            this.a = i;
            this.b = i2;
            this.c = i3;
            this.d = str;
            this.e = str2;
            this.f = l;
        }

        public final boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof d)) {
                return false;
            }
            d dVar = (d) obj;
            return this.a == dVar.a && this.b == dVar.b && this.c == dVar.c && cr4.b(this.d, dVar.d) && cr4.b(this.e, dVar.e) && cr4.b(this.f, dVar.f);
        }

        public final int hashCode() {
            int iA = fi7.a(this.c, fi7.a(this.b, Integer.hashCode(this.a) * 31, 31), 31);
            String str = this.d;
            int iHashCode = (iA + (str == null ? 0 : str.hashCode())) * 31;
            String str2 = this.e;
            int iHashCode2 = (iHashCode + (str2 == null ? 0 : str2.hashCode())) * 31;
            Long l = this.f;
            return iHashCode2 + (l != null ? l.hashCode() : 0);
        }

        public final String toString() {
            StringBuilder sbR = vw2.r("NextEpisodeInfo(showTmdbId=", this.a, ", season=", ", episode=", this.b);
            n41.ac(sbR, this.c, ", title=", this.d, ", stillUrl=");
            sbR.append(this.e);
            sbR.append(", airDateMillis=");
            sbR.append(this.f);
            sbR.append(")");
            return sbR.toString();
        }
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class e {
        static {
            int[] iArr = new int[h.d.values().length];
            try {
                iArr[0] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                h.d dVar = h.d.a;
                iArr[1] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                h.d dVar2 = h.d.a;
                iArr[2] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                h.d dVar3 = h.d.a;
                iArr[3] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            int[] iArr2 = new int[a.values().length];
            try {
                iArr2[0] = 1;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a aVar = a.a;
                iArr2[1] = 2;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                a aVar2 = a.a;
                iArr2[2] = 3;
            } catch (NoSuchFieldError unused7) {
            }
        }
    }

    public VideoPlayerActivity() {
        ik2 ik2Var = ik2.a;
        this.ce = ik2Var;
        this.ch = new LinkedHashSet();
        this.cq = new Handler(Looper.getMainLooper());
        this.cu = -1;
        this.cx = -1.0f;
        this.B = -1L;
        this.C = new sga(this, 9);
        this.E = new sga(this, 0);
        this.I = ik2Var;
        this.R = 30000L;
        this.S = ik2Var;
        this.W = 100;
        this.X = 5;
        kx kxVar = new kx();
        kxVar.b = new byte[0];
        this.c0 = kxVar;
        this.d0 = new wt0();
        this.e0 = new fh2();
        this.t0 = 30;
        this.x0 = new lx(this, 1);
        this.y0 = new LinkedHashSet();
        this.E0 = 2;
        this.J0 = -1L;
        this.O0 = wo5.j(new q07("en", y41.an("en", "eng")), new q07("es", y41.an("es", "spa")), new q07("fr", y41.an("fr", "fra", "fre")), new q07("de", y41.an("de", "deu", "ger")), new q07("it", y41.an("it", "ita")), new q07("pt", y41.an("pt", "por")), new q07("pt-BR", y41.an("pt-br", "pb", "pob")), new q07("ja", y41.an("ja", "jpn")), new q07("ko", y41.an("ko", "kor")), new q07("zh", y41.an("zh", "zho", "chi", "cmn", "yue")), new q07("ru", y41.an("ru", "rus")), new q07("ar", y41.an("ar", "ara")), new q07("hi", y41.an("hi", "hin")), new q07("nl", y41.an("nl", "nld", "dut")), new q07("pl", y41.an("pl", "pol")), new q07("sv", y41.an("sv", "swe")), new q07("no", y41.an("no", CmcdConfiguration.KEY_NEXT_OBJECT_REQUEST, "nob", "nno")), new q07("da", y41.an("da", "dan")), new q07("fi", y41.an("fi", "fin")), new q07("tr", y41.an("tr", "tur")), new q07("th", y41.an("th", "tha")), new q07("vi", y41.an("vi", "vie")), new q07(TtmlNode.ATTR_ID, y41.an(TtmlNode.ATTR_ID, "ind")), new q07("he", y41.an("he", "heb")), new q07("el", y41.an("el", "ell", "gre")), new q07("cs", y41.an("cs", "ces", "cze")), new q07("hu", y41.an("hu", "hun")), new q07("ro", y41.an("ro", "ron", "rum")), new q07("uk", y41.an("uk", "ukr")));
        this.P0 = st.ao(new String[]{MimeTypes.APPLICATION_SUBRIP, MimeTypes.TEXT_VTT, MimeTypes.APPLICATION_TTML, MimeTypes.TEXT_SSA, MimeTypes.APPLICATION_TX3G, MimeTypes.APPLICATION_CEA608, MimeTypes.APPLICATION_CEA708, MimeTypes.APPLICATION_MP4CEA608, "application/x-mp4-cea-708", NanoHTTPD.MIME_PLAINTEXT});
    }

    public static String ak(long j) {
        long j2 = j / ((long) 1000);
        long j3 = 3600;
        long j4 = j2 / j3;
        long j5 = 60;
        long j6 = (j2 % j3) / j5;
        long j7 = j2 % j5;
        return j4 > 0 ? String.format("%d:%02d:%02d", Arrays.copyOf(new Object[]{Long.valueOf(j4), Long.valueOf(j6), Long.valueOf(j7)}, 3)) : String.format("%d:%02d", Arrays.copyOf(new Object[]{Long.valueOf(j6), Long.valueOf(j7)}, 2));
    }

    public static String ao(PlaybackException playbackException) {
        Throwable th = playbackException;
        while (th.getCause() != null) {
            Throwable cause = th.getCause();
            cr4.d(cause);
            th = cause;
        }
        String message = th.getMessage();
        return message == null ? "" : message;
    }

    public static boolean as(PlaybackException playbackException, Class cls) {
        for (Throwable cause = playbackException; cause != null; cause = cause.getCause()) {
            if (cls.isInstance(cause)) {
                return true;
            }
        }
        return false;
    }

    public static float bp(float f) {
        if (23.75f <= f && f <= 23.988f) {
            return 23.976f;
        }
        if (23.988f <= f && f <= 24.2f) {
            return 24.0f;
        }
        if (24.9f <= f && f <= 25.1f) {
            return 25.0f;
        }
        if (29.9f <= f && f <= 29.985f) {
            return 29.97f;
        }
        if (29.985f <= f && f <= 30.1f) {
            return 30.0f;
        }
        if (49.9f <= f && f <= 50.1f) {
            return 50.0f;
        }
        if (59.9f <= f && f <= 59.97f) {
            return 59.94f;
        }
        if (59.97f > f || f > 60.1f) {
            return f;
        }
        return 60.0f;
    }

    public static String br(String str) {
        Object next;
        String str2;
        Iterator it = U0.iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            if (cr4.b(((q07) next).a, str)) {
                break;
            }
        }
        q07 q07Var = (q07) next;
        return (q07Var == null || (str2 = (String) q07Var.b) == null) ? "Default" : str2;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:17:0x0058  */
    /* JADX WARN: Removed duplicated region for block: B:97:0x0177  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void e(VideoPlayerActivity videoPlayerActivity) {
        String displayLanguage;
        String upperCase;
        ExoPlayer exoPlayer = videoPlayerActivity.bm;
        if (exoPlayer != null) {
            Tracks currentTracks = exoPlayer.getCurrentTracks();
            cr4.f(currentTracks, "getCurrentTracks(...)");
            ArrayList arrayList = new ArrayList();
            int size = currentTracks.getGroups().size();
            for (int i = 0; i < size; i++) {
                Tracks.Group group = currentTracks.getGroups().get(i);
                if (group.getType() == 1) {
                    int i2 = group.length;
                    for (int i3 = 0; i3 < i2; i3++) {
                        Format trackFormat = group.getTrackFormat(i3);
                        cr4.f(trackFormat, "getTrackFormat(...)");
                        StringBuilder sb = new StringBuilder();
                        String str = trackFormat.language;
                        if (str != null) {
                            displayLanguage = Locale.forLanguageTag(str).getDisplayLanguage();
                            if (cr4.b(displayLanguage, str)) {
                                displayLanguage = null;
                            }
                        }
                        String str2 = trackFormat.label;
                        if (str2 == null || n89.ab(str2)) {
                            str2 = null;
                        }
                        if (str2 != null && displayLanguage != null && !str2.equalsIgnoreCase(displayLanguage)) {
                            sb.append(displayLanguage + " (" + str2 + ")");
                        } else if (str2 != null) {
                            sb.append(str2);
                        } else if (displayLanguage != null) {
                            sb.append(displayLanguage);
                        } else {
                            sb.append("Track " + (i3 + 1));
                        }
                        String str3 = trackFormat.sampleMimeType;
                        if (str3 != null) {
                            switch (str3.hashCode()) {
                                case -2123537834:
                                    if (str3.equals(MimeTypes.AUDIO_E_AC3_JOC)) {
                                        upperCase = "EAC3 Atmos";
                                    } else {
                                        upperCase = n89.ai(str3, "audio/").toUpperCase(Locale.ROOT);
                                        cr4.f(upperCase, "toUpperCase(...)");
                                    }
                                    break;
                                case -1365340241:
                                    if (str3.equals(MimeTypes.AUDIO_DTS_EXPRESS)) {
                                        upperCase = "DTS Express";
                                        break;
                                    }
                                    break;
                                case -1095064472:
                                    if (str3.equals(MimeTypes.AUDIO_DTS)) {
                                        upperCase = "DTS";
                                        break;
                                    }
                                    break;
                                case -1003765268:
                                    if (str3.equals(MimeTypes.AUDIO_VORBIS)) {
                                        upperCase = "Vorbis";
                                        break;
                                    }
                                    break;
                                case -53558318:
                                    if (str3.equals(MimeTypes.AUDIO_AAC)) {
                                        upperCase = "AAC";
                                        break;
                                    }
                                    break;
                                case 187078296:
                                    if (str3.equals(MimeTypes.AUDIO_AC3)) {
                                        upperCase = RtpPayloadFormat.RTP_MEDIA_AC3;
                                        break;
                                    }
                                    break;
                                case 187078297:
                                    if (str3.equals(MimeTypes.AUDIO_AC4)) {
                                        upperCase = "AC4";
                                        break;
                                    }
                                    break;
                                case 187094639:
                                    if (str3.equals(MimeTypes.AUDIO_RAW)) {
                                        upperCase = "PCM";
                                        break;
                                    }
                                    break;
                                case 550520934:
                                    if (str3.equals(MimeTypes.AUDIO_DTS_X)) {
                                        upperCase = "DTS:X";
                                        break;
                                    }
                                    break;
                                case 1504578661:
                                    if (str3.equals(MimeTypes.AUDIO_E_AC3)) {
                                        upperCase = "EAC3";
                                        break;
                                    }
                                    break;
                                case 1504619009:
                                    if (str3.equals(MimeTypes.AUDIO_FLAC)) {
                                        upperCase = "FLAC";
                                        break;
                                    }
                                    break;
                                case 1504831518:
                                    if (str3.equals(MimeTypes.AUDIO_MPEG)) {
                                        upperCase = "MP3";
                                        break;
                                    }
                                    break;
                                case 1504891608:
                                    if (str3.equals(MimeTypes.AUDIO_OPUS)) {
                                        upperCase = "Opus";
                                        break;
                                    }
                                    break;
                                case 1505942594:
                                    if (str3.equals(MimeTypes.AUDIO_DTS_HD)) {
                                        upperCase = "DTS-HD";
                                        break;
                                    }
                                    break;
                                case 1556697186:
                                    if (str3.equals(MimeTypes.AUDIO_TRUEHD)) {
                                        upperCase = "TrueHD";
                                        break;
                                    }
                                    break;
                            }
                            sb.append(" · ".concat(upperCase));
                        }
                        int i4 = trackFormat.channelCount;
                        Integer numValueOf = Integer.valueOf(i4);
                        if (i4 <= 0) {
                            numValueOf = null;
                        }
                        if (numValueOf != null) {
                            int iIntValue = numValueOf.intValue();
                            sb.append(" " + (iIntValue != 1 ? iIntValue != 2 ? iIntValue != 6 ? iIntValue != 8 ? n41.h(iIntValue, "ch") : "7.1" : "5.1" : "Stereo" : "Mono"));
                        }
                        int i5 = trackFormat.bitrate;
                        Integer numValueOf2 = i5 > 0 ? Integer.valueOf(i5) : null;
                        if (numValueOf2 != null) {
                            sb.append(" " + (numValueOf2.intValue() / 1000) + "kbps");
                        }
                        arrayList.add(new q07(sb.toString(), new TrackSelectionOverride(group.getMediaTrackGroup(), i3)));
                    }
                }
            }
            String string = videoPlayerActivity.getString(R.string.player_volume_boost_label, videoPlayerActivity.am().formatVolumeBoostPercent());
            cr4.f(string, "getString(...)");
            long j = videoPlayerActivity.b0;
            double d2 = j / 1000.0d;
            String string2 = videoPlayerActivity.getString(R.string.player_audio_delay_label, j >= 0 ? String.format("+%.1fs", Arrays.copyOf(new Object[]{Double.valueOf(d2)}, 1)) : String.format("%.1fs", Arrays.copyOf(new Object[]{Double.valueOf(d2)}, 1)));
            cr4.f(string2, "getString(...)");
            String string3 = videoPlayerActivity.getString(R.string.player_center_boost_label, videoPlayerActivity.am().formatCenterChannelBoost());
            cr4.f(string3, "getString(...)");
            String string4 = videoPlayerActivity.getString(R.string.player_night_mode_label, videoPlayerActivity.am().formatNightModeLevel());
            cr4.f(string4, "getString(...)");
            ArrayList arrayListAr = y41.ar(string, string2, string3, string4);
            ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                arrayList2.add((String) ((q07) it.next()).a);
            }
            arrayListAr.addAll(arrayList2);
            new gv3(videoPlayerActivity, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity.getString(R.string.player_dialog_audio_title)).setItems((CharSequence[]) arrayListAr.toArray(new String[0]), (DialogInterface.OnClickListener) new x3(videoPlayerActivity, arrayList, 18)).show();
        }
        videoPlayerActivity.be();
    }

    /* JADX WARN: Removed duplicated region for block: B:141:0x0208 A[ADDED_TO_REGION, REMOVE, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:84:0x01ff A[ADDED_TO_REGION] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final void f(VideoPlayerActivity videoPlayerActivity, Tracks tracks) {
        String str;
        boolean z;
        boolean z2;
        boolean z3;
        boolean z4;
        int i;
        int i2;
        int i3;
        int i4;
        boolean zContains;
        int i5;
        boolean z5;
        if (videoPlayerActivity.u0) {
            return;
        }
        int i6 = 1;
        videoPlayerActivity.u0 = true;
        ExoPlayer exoPlayer = videoPlayerActivity.bm;
        if (exoPlayer == null) {
            return;
        }
        String defaultAudioLanguage = videoPlayerActivity.bo.getDefaultAudioLanguage();
        if (defaultAudioLanguage == null) {
            defaultAudioLanguage = "en";
        }
        String defaultSubtitleLanguage = videoPlayerActivity.bo.getDefaultSubtitleLanguage();
        Log.w("VideoPlayerActivity", "applyDefaultTrackSelection: subtitlesEnabled=" + videoPlayerActivity.bo.getSubtitlesEnabledByDefault() + ", preferredLang=" + defaultSubtitleLanguage + ", trackGroups=" + tracks.getGroups().size());
        TrackSelectionParameters.Builder builderBuildUpon = exoPlayer.getTrackSelectionParameters().buildUpon();
        cr4.f(builderBuildUpon, "buildUpon(...)");
        int size = tracks.getGroups().size();
        Format format = null;
        boolean z6 = false;
        int i7 = -1;
        int i8 = 0;
        int i9 = -1;
        boolean z7 = false;
        boolean z8 = false;
        while (true) {
            str = " mime=";
            if (i8 >= size) {
                break;
            }
            Tracks.Group group = tracks.getGroups().get(i8);
            int i10 = size;
            int type = group.getType();
            Format format2 = format;
            if (type != i6) {
                if (type == 3) {
                    if (videoPlayerActivity.bo.getSubtitlesEnabledByDefault() || !(defaultSubtitleLanguage == null || defaultSubtitleLanguage.length() == 0)) {
                        if (defaultSubtitleLanguage != null && defaultSubtitleLanguage.length() != 0 && !z6) {
                            int i11 = group.length;
                            int i12 = i9;
                            Format format3 = format2;
                            int i13 = 0;
                            while (true) {
                                if (i13 >= i11) {
                                    i9 = i12;
                                    format = format3;
                                    break;
                                }
                                int i14 = i11;
                                Format trackFormat = group.getTrackFormat(i13);
                                cr4.f(trackFormat, "getTrackFormat(...)");
                                Format format4 = format3;
                                if (videoPlayerActivity.ay(trackFormat.language, defaultSubtitleLanguage)) {
                                    String str2 = trackFormat.sampleMimeType;
                                    if (str2 == null || str2.length() == 0) {
                                        z4 = z6;
                                        i4 = i7;
                                        zContains = false;
                                    } else {
                                        z4 = z6;
                                        Set set = videoPlayerActivity.P0;
                                        i4 = i7;
                                        String lowerCase = str2.toLowerCase(Locale.ROOT);
                                        cr4.f(lowerCase, "toLowerCase(...)");
                                        zContains = set.contains(lowerCase);
                                    }
                                    if (zContains) {
                                        builderBuildUpon = builderBuildUpon.setTrackTypeDisabled(3, false).setOverrideForType(new TrackSelectionOverride(group.getMediaTrackGroup(), i13));
                                        String str3 = trackFormat.language;
                                        String str4 = trackFormat.sampleMimeType;
                                        StringBuilder sbR = vw2.r("applyDefaultTrackSelection: selected subtitle group=", i8, " track=", " lang=", i13);
                                        sbR.append(str3);
                                        sbR.append(" mime=");
                                        sbR.append(str4);
                                        Log.w("VideoPlayerActivity", sbR.toString());
                                        String str5 = trackFormat.language;
                                        int i15 = i13;
                                        String str6 = str5 == null ? "Unknown" : str5;
                                        String str7 = trackFormat.label;
                                        if (str7 != null) {
                                            str5 = str7;
                                        } else if (str5 == null) {
                                            str5 = "Subtitle";
                                        }
                                        int i16 = trackFormat.selectionFlags;
                                        if ((i16 & 2) != 0) {
                                            i5 = i4;
                                            z5 = true;
                                        } else {
                                            i5 = i4;
                                            z5 = false;
                                        }
                                        videoPlayerActivity.T = new t.a(i15, i8, str6, str5, z5, (i16 & 1) != 0, trackFormat.sampleMimeType);
                                        str = " mime=";
                                        i7 = i5;
                                        i9 = i12;
                                        format = format4;
                                        z6 = true;
                                    } else {
                                        i2 = i13;
                                        i = i4;
                                        if (i == -1) {
                                            String str8 = trackFormat.language;
                                            String str9 = trackFormat.sampleMimeType;
                                            StringBuilder sbR2 = vw2.r("applyDefaultTrackSelection: bitmap fallback candidate group=", i8, " track=", " lang=", i2);
                                            sbR2.append(str8);
                                            sbR2.append(" mime=");
                                            sbR2.append(str9);
                                            Log.w("VideoPlayerActivity", sbR2.toString());
                                            i12 = i2;
                                            i3 = i8;
                                            format3 = trackFormat;
                                        }
                                        i13 = i2 + 1;
                                        i7 = i3;
                                        i11 = i14;
                                        z6 = z4;
                                    }
                                } else {
                                    z4 = z6;
                                    i = i7;
                                    i2 = i13;
                                }
                                i3 = i;
                                format3 = format4;
                                i13 = i2 + 1;
                                i7 = i3;
                                i11 = i14;
                                z6 = z4;
                            }
                            if (z8 && (z6 || z7)) {
                                break;
                            }
                            i8++;
                            size = i10;
                            i6 = 1;
                        }
                    } else if (!z7) {
                        builderBuildUpon = builderBuildUpon.setTrackTypeDisabled(3, true);
                        format = format2;
                        z7 = true;
                        if (z8) {
                        }
                        i8++;
                        size = i10;
                        i6 = 1;
                    }
                }
                z3 = z6;
                format = format2;
                z6 = z3;
                if (z8) {
                }
                i8++;
                size = i10;
                i6 = 1;
            } else {
                z3 = z6;
                if ((defaultAudioLanguage.length() == 0) || z8) {
                    format = format2;
                    z6 = z3;
                    if (z8) {
                    }
                    i8++;
                    size = i10;
                    i6 = 1;
                } else {
                    int i17 = group.length;
                    for (int i18 = 0; i18 < i17; i18++) {
                        Format trackFormat2 = group.getTrackFormat(i18);
                        cr4.f(trackFormat2, "getTrackFormat(...)");
                        if (videoPlayerActivity.ay(trackFormat2.language, defaultAudioLanguage)) {
                            builderBuildUpon = builderBuildUpon.setOverrideForType(new TrackSelectionOverride(group.getMediaTrackGroup(), i18));
                            format = format2;
                            z6 = z3;
                            z8 = true;
                            break;
                        }
                    }
                    format = format2;
                    z6 = z3;
                    if (z8) {
                    }
                    i8++;
                    size = i10;
                    i6 = 1;
                }
            }
        }
        boolean z9 = z7;
        boolean z10 = z8;
        if (z6 || z9 || format == null) {
            z = false;
            z2 = z6;
        } else {
            z = false;
            builderBuildUpon = builderBuildUpon.setTrackTypeDisabled(3, false).setOverrideForType(new TrackSelectionOverride(tracks.getGroups().get(i7).getMediaTrackGroup(), i9));
            String str10 = format.sampleMimeType;
            StringBuilder sbR3 = vw2.r("applyDefaultTrackSelection: using bitmap fallback group=", i7, " track=", str, i9);
            sbR3.append(str10);
            Log.w("VideoPlayerActivity", sbR3.toString());
            String str11 = format.language;
            String str12 = str11 == null ? "Unknown" : str11;
            String str13 = format.label;
            String str14 = str13 == null ? str11 == null ? "Subtitle" : str11 : str13;
            int i19 = format.selectionFlags;
            videoPlayerActivity.T = new t.a(i9, i7, str12, str14, (i19 & 2) != 0, (i19 & 1) != 0, format.sampleMimeType);
            z2 = true;
        }
        if (!videoPlayerActivity.bo.getSubtitlesEnabledByDefault() && !z9) {
            builderBuildUpon = builderBuildUpon.setTrackTypeDisabled(3, true);
        }
        exoPlayer.setTrackSelectionParameters(builderBuildUpon.build());
        Log.w("VideoPlayerActivity", "applyDefaultTrackSelection: result subtitleMatch=" + z2 + " audioMatch=" + z10 + " subtitlesDisabled=" + z9);
        if (videoPlayerActivity.bo.getSubtitlesEnabledByDefault()) {
            if (!((defaultSubtitleLanguage == null || defaultSubtitleLanguage.length() == 0) ? true : z) && !z2 && !videoPlayerActivity.v0) {
                videoPlayerActivity.v0 = true;
                Log.w("VideoPlayerActivity", "No embedded subtitle match for '" + defaultSubtitleLanguage + "', fetching external subtitles...");
                videoPlayerActivity.az();
            }
        }
        if (!videoPlayerActivity.S.isEmpty() || videoPlayerActivity.V || videoPlayerActivity.v0) {
            return;
        }
        videoPlayerActivity.az();
    }

    public static final void g(final VideoPlayerActivity videoPlayerActivity) {
        ExoPlayer exoPlayer;
        Format videoFormat;
        if (!videoPlayerActivity.bo.getAutoFramerateEnabled()) {
            ExecutorService executorService = kq.a;
            kq.h("FrameRate", "Auto frame rate disabled, skipping");
            return;
        }
        if (videoPlayerActivity.cv || (exoPlayer = videoPlayerActivity.bm) == null || (videoFormat = exoPlayer.getVideoFormat()) == null) {
            return;
        }
        float f = videoFormat.frameRate;
        if (f > 0.0f && f < 10.0f) {
            ExecutorService executorService2 = kq.a;
            kq.h("FrameRate", "Container reports implausible frame rate: " + f + "fps, skipping frame rate matching");
            videoPlayerActivity.cv = true;
            return;
        }
        if (f <= 0.0f) {
            float f2 = videoPlayerActivity.cx;
            if (f2 > 0.0f) {
                ExecutorService executorService3 = kq.a;
                kq.h("FrameRate", "Container frame rate unavailable, using preflight result: " + f2 + " fps");
                videoPlayerActivity.z(videoPlayerActivity.cx);
                return;
            }
            ExecutorService executorService4 = kq.a;
            kq.h("FrameRate", "Container frame rate unavailable (" + f + "), detecting from frame timestamps...");
            final ArrayList arrayList = new ArrayList();
            final AtomicBoolean atomicBoolean = new AtomicBoolean(false);
            exoPlayer.setVideoFrameMetadataListener(new VideoFrameMetadataListener() { // from class: wga
                @Override // androidx.media3.exoplayer.video.VideoFrameMetadataListener
                public final void onVideoFrameAboutToBeRendered(long j, long j2, Format format, MediaFormat mediaFormat) {
                    Iterable iterable;
                    final VideoPlayerActivity videoPlayerActivity2 = videoPlayerActivity;
                    Handler handler = videoPlayerActivity2.cq;
                    long[] jArr = VideoPlayerActivity.R0;
                    cr4.g(format, "format");
                    AtomicBoolean atomicBoolean2 = atomicBoolean;
                    if (atomicBoolean2.get()) {
                        return;
                    }
                    ArrayList arrayList2 = arrayList;
                    final int i = 1;
                    if (arrayList2.isEmpty() && mediaFormat != null) {
                        try {
                            if (mediaFormat.containsKey("frame-rate")) {
                                float integer = mediaFormat.getInteger("frame-rate");
                                if (integer > 0.0f) {
                                    atomicBoolean2.set(true);
                                    final float fBp = VideoPlayerActivity.bp(integer);
                                    ExecutorService executorService5 = kq.a;
                                    kq.h("FrameRate", "Detected frame rate from codec output: " + integer + "fps (snapped: " + fBp + "fps)");
                                    final int i2 = 0;
                                    handler.post(new Runnable() { // from class: yga
                                        @Override // java.lang.Runnable
                                        public final void run() {
                                            int i3 = i2;
                                            float f3 = fBp;
                                            VideoPlayerActivity videoPlayerActivity3 = videoPlayerActivity2;
                                            switch (i3) {
                                                case 0:
                                                    long[] jArr2 = VideoPlayerActivity.R0;
                                                    videoPlayerActivity3.z(f3);
                                                    break;
                                                default:
                                                    long[] jArr3 = VideoPlayerActivity.R0;
                                                    videoPlayerActivity3.z(f3);
                                                    break;
                                            }
                                        }
                                    });
                                    return;
                                }
                            }
                        } catch (Exception unused) {
                        }
                    }
                    arrayList2.add(Long.valueOf(j));
                    if (arrayList2.size() >= 33) {
                        Iterator it = y41.u(arrayList2, 3).iterator();
                        if (it.hasNext()) {
                            ArrayList arrayList3 = new ArrayList();
                            Object next = it.next();
                            while (it.hasNext()) {
                                Object next2 = it.next();
                                arrayList3.add(Long.valueOf(((Number) next2).longValue() - ((Number) next).longValue()));
                                next = next2;
                            }
                            iterable = arrayList3;
                        } else {
                            iterable = ik2.a;
                        }
                        ArrayList arrayList4 = new ArrayList();
                        for (Object obj : iterable) {
                            if (((Number) obj).longValue() > 0) {
                                arrayList4.add(obj);
                            }
                        }
                        if (arrayList4.size() >= 15) {
                            List listBi = y41.bi(arrayList4);
                            long jLongValue = ((Number) listBi.get(listBi.size() / 2)).longValue();
                            float f3 = (float) (1000000.0d / jLongValue);
                            if (f3 < 10.0f) {
                                atomicBoolean2.set(true);
                                ExecutorService executorService6 = kq.a;
                                kq.h("FrameRate", "Detected implausible frame rate from timestamps: " + f3 + "fps (median=" + jLongValue + "us), skipping");
                                return;
                            }
                            final float fBp2 = VideoPlayerActivity.bp(f3);
                            atomicBoolean2.set(true);
                            ExecutorService executorService7 = kq.a;
                            kq.h("FrameRate", "Detected frame rate from timestamps: raw=" + f3 + "fps, snapped=" + fBp2 + "fps (median=" + jLongValue + "us, " + arrayList4.size() + " samples)");
                            handler.post(new Runnable() { // from class: yga
                                @Override // java.lang.Runnable
                                public final void run() {
                                    int i3 = i;
                                    float f32 = fBp2;
                                    VideoPlayerActivity videoPlayerActivity3 = videoPlayerActivity2;
                                    switch (i3) {
                                        case 0:
                                            long[] jArr2 = VideoPlayerActivity.R0;
                                            videoPlayerActivity3.z(f32);
                                            break;
                                        default:
                                            long[] jArr3 = VideoPlayerActivity.R0;
                                            videoPlayerActivity3.z(f32);
                                            break;
                                    }
                                }
                            });
                        }
                    }
                }
            });
            kq.h("FrameRate", "Started frame rate detection from frame timestamps (target: 33 frames)");
            return;
        }
        if (23.95f <= f && f <= 24.05f) {
            float f3 = videoPlayerActivity.cx;
            if (f3 > 0.0f) {
                float fBp = bp(f3);
                float fBp2 = bp(f);
                if (fBp != fBp2) {
                    ExecutorService executorService5 = kq.a;
                    kq.h("FrameRate", "Cinema disambiguation: track=" + f + "fps (→" + fBp2 + "), preflight=" + videoPlayerActivity.cx + "fps (→" + fBp + ") — using preflight");
                    videoPlayerActivity.z(fBp);
                    return;
                }
            }
        }
        videoPlayerActivity.z(bp(f));
    }

    public static final void h(VideoPlayerActivity videoPlayerActivity) {
        float volumeMultiplier = videoPlayerActivity.am().getVolumeMultiplier();
        if (videoPlayerActivity.am().getAudioPassthrough() && volumeMultiplier > 1.0f) {
            videoPlayerActivity.am().setVolumeMultiplier(1.0f);
            volumeMultiplier = 1.0f;
        }
        videoPlayerActivity.ac(volumeMultiplier);
    }

    public static final boolean i(VideoPlayerActivity videoPlayerActivity, long j) throws NoSuchAlgorithmException, KeyManagementException {
        int i = videoPlayerActivity.B0;
        if (i >= 5) {
            Log.w("VideoPlayerActivity", "Exhausted all 5 parser recovery attempts");
            return false;
        }
        long j2 = R0[i <= 4 ? i : 4];
        int i2 = i + 1;
        videoPlayerActivity.B0 = i2;
        Log.w("VideoPlayerActivity", "Parser error at " + j + "ms — recovery attempt " + i2 + "/5 (skip forward " + j2 + "ms)");
        ExoPlayer exoPlayer = videoPlayerActivity.bm;
        if (exoPlayer != null) {
            c cVar = videoPlayerActivity.g0;
            if (cVar != null) {
                exoPlayer.removeListener(cVar);
            }
            try {
                exoPlayer.stop();
                exoPlayer.clearMediaItems();
                exoPlayer.release();
            } catch (Exception unused) {
            }
        }
        videoPlayerActivity.bm = null;
        long j3 = j2 + j;
        ExecutorService executorService = kq.a;
        kq.h("VideoPlayer", "Parser recovery #" + videoPlayerActivity.B0 + ": skipping forward " + j + "ms -> " + j3 + "ms");
        videoPlayerActivity.bc(j3);
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object j(VideoPlayerActivity videoPlayerActivity, List list, ContinuationImpl continuationImpl) {
        n nVar;
        VideoPlayerActivity videoPlayerActivity2;
        String str;
        if (continuationImpl instanceof n) {
            nVar = (n) continuationImpl;
            int i = nVar.e;
            if ((i & Integer.MIN_VALUE) != 0) {
                nVar.e = i - Integer.MIN_VALUE;
            } else {
                nVar = new n(videoPlayerActivity, continuationImpl);
            }
        }
        Object obj = nVar.c;
        ck1 ck1Var = ck1.a;
        int i2 = nVar.e;
        e6a e6aVar = e6a.a;
        if (i2 == 0) {
            s38.b(obj);
            if (!videoPlayerActivity.bo.getSubtitlesEnabledByDefault()) {
                Log.w("VideoPlayerActivity", "autoSelectSubtitle: subtitles not enabled by default, skipping");
                return e6aVar;
            }
            com.strmr.ps.data.subtitle.t tVar = videoPlayerActivity.T;
            if (tVar != null && !(tVar instanceof t.c)) {
                Log.w("VideoPlayerActivity", "autoSelectSubtitle: subtitle already selected (" + iw7.a.getOrCreateKotlinClass(tVar.getClass()).getSimpleName() + "), skipping");
                return e6aVar;
            }
            String defaultSubtitleLanguage = videoPlayerActivity.bo.getDefaultSubtitleLanguage();
            if (defaultSubtitleLanguage == null || defaultSubtitleLanguage.length() == 0) {
                Log.w("VideoPlayerActivity", "autoSelectSubtitle: no preferred language, skipping");
                return e6aVar;
            }
            SubtitleManager subtitleManagerAq = videoPlayerActivity.aq();
            nVar.a = videoPlayerActivity;
            nVar.b = defaultSubtitleLanguage;
            nVar.e = 1;
            Object objI = subtitleManagerAq.i(list, nVar);
            if (objI == ck1Var) {
                return ck1Var;
            }
            videoPlayerActivity2 = videoPlayerActivity;
            str = defaultSubtitleLanguage;
            obj = objI;
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            str = nVar.b;
            videoPlayerActivity2 = nVar.a;
            s38.b(obj);
        }
        com.strmr.ps.data.subtitle.t tVar2 = (com.strmr.ps.data.subtitle.t) obj;
        if (tVar2 == null) {
            Boxing.boxInt(Log.w("VideoPlayerActivity", "autoSelectSubtitle: no matching subtitle found for '" + str + "'"));
            return e6aVar;
        }
        Log.w("VideoPlayerActivity", "autoSelectSubtitle: applying " + iw7.a.getOrCreateKotlinClass(tVar2.getClass()).getSimpleName() + " subtitle");
        videoPlayerActivity2.aa(tVar2);
        return e6aVar;
    }

    /* JADX WARN: Removed duplicated region for block: B:58:0x00e0  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x00e3  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x00fe  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Serializable k(VideoPlayerActivity videoPlayerActivity, int i, int i2, int i3, ContinuationImpl continuationImpl) {
        o oVar;
        TMDBSeasonDetails tMDBSeasonDetails;
        Object next;
        int i4;
        List<TMDBEpisode> episodes;
        TMDBSeasonDetails tMDBSeasonDetails2;
        TMDBEpisode tMDBEpisode;
        List<TMDBEpisode> episodes2;
        if (continuationImpl instanceof o) {
            oVar = (o) continuationImpl;
            int i5 = oVar.i;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                oVar.i = i5 - Integer.MIN_VALUE;
            } else {
                oVar = new o(videoPlayerActivity, continuationImpl);
            }
        }
        Object seasonDetails = oVar.e;
        ck1 ck1Var = ck1.a;
        int i6 = oVar.i;
        try {
        } catch (Exception unused) {
            tMDBSeasonDetails = null;
        }
        if (i6 == 0) {
            s38.b(seasonDetails);
            TMDBApiService tMDBApiServiceAr = videoPlayerActivity.ar();
            oVar.a = videoPlayerActivity;
            oVar.b = i;
            oVar.c = i2;
            oVar.d = i3;
            oVar.i = 1;
            seasonDetails = tMDBApiServiceAr.getSeasonDetails(i, i2, oVar);
            if (seasonDetails == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i6 != 1) {
                if (i6 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                i4 = oVar.b;
                try {
                    s38.b(seasonDetails);
                    tMDBSeasonDetails2 = (TMDBSeasonDetails) seasonDetails;
                } catch (Exception unused2) {
                    tMDBSeasonDetails2 = null;
                }
                tMDBEpisode = (tMDBSeasonDetails2 != null || (episodes2 = tMDBSeasonDetails2.getEpisodes()) == null) ? null : (TMDBEpisode) y41.ab(y41.bj(new fha(), episodes2));
                if (tMDBEpisode != null) {
                    return null;
                }
                Integer episodeNumber = tMDBEpisode.getEpisodeNumber();
                return new hx9(Boxing.boxInt(i4 + 1), Boxing.boxInt(episodeNumber != null ? episodeNumber.intValue() : 1), tMDBEpisode);
            }
            i3 = oVar.d;
            i2 = oVar.c;
            i = oVar.b;
            videoPlayerActivity = oVar.a;
            s38.b(seasonDetails);
        }
        tMDBSeasonDetails = (TMDBSeasonDetails) seasonDetails;
        Iterator it = ((tMDBSeasonDetails == null || (episodes = tMDBSeasonDetails.getEpisodes()) == null) ? ik2.a : y41.bj(new eha(), episodes)).iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            Integer episodeNumber2 = ((TMDBEpisode) next).getEpisodeNumber();
            if ((episodeNumber2 != null ? episodeNumber2.intValue() : 0) == i3 + 1) {
                break;
            }
        }
        TMDBEpisode tMDBEpisode2 = (TMDBEpisode) next;
        if (tMDBEpisode2 != null) {
            return new hx9(Boxing.boxInt(i2), Boxing.boxInt(i3 + 1), tMDBEpisode2);
        }
        try {
            oVar.a = null;
            oVar.b = i2;
            oVar.i = 2;
            seasonDetails = videoPlayerActivity.ar().getSeasonDetails(i, i2 + 1, oVar);
        } catch (Exception unused3) {
            i4 = i2;
            tMDBSeasonDetails2 = null;
        }
        if (seasonDetails == ck1Var) {
            return ck1Var;
        }
        i4 = i2;
        tMDBSeasonDetails2 = (TMDBSeasonDetails) seasonDetails;
        if (tMDBSeasonDetails2 != null) {
        }
        if (tMDBEpisode != null) {
        }
    }

    public static final void l(VideoPlayerActivity videoPlayerActivity) {
        boolean z = videoPlayerActivity.k0;
        boolean zAx = videoPlayerActivity.ax();
        videoPlayerActivity.k0 = zAx;
        if (z != zAx) {
            ExecutorService executorService = kq.a;
            kq.h("VideoPlayerActivity", "Bluetooth audio state changed: " + z + " -> " + zAx);
            ExoPlayer exoPlayer = videoPlayerActivity.bm;
            if (exoPlayer == null) {
                exoPlayer = null;
            }
            if (exoPlayer == null) {
                return;
            }
            TrackSelector trackSelector = exoPlayer.getTrackSelector();
            DefaultTrackSelector defaultTrackSelector = trackSelector instanceof DefaultTrackSelector ? (DefaultTrackSelector) trackSelector : null;
            if (defaultTrackSelector == null) {
                return;
            }
            boolean z2 = videoPlayerActivity.bo.getTunnelingEnabled() && !videoPlayerActivity.k0;
            int i = (!videoPlayerActivity.am().getAudioPassthrough() || videoPlayerActivity.k0) ? 2 : Integer.MAX_VALUE;
            if (videoPlayerActivity.k0) {
                kq.h("VideoPlayerActivity", "Bluetooth connected during playback — disabling tunneling and forcing stereo PCM");
            } else {
                kq.h("VideoPlayerActivity", "Bluetooth disconnected — restoring original audio settings");
            }
            defaultTrackSelector.setParameters(defaultTrackSelector.buildUponParameters().setTunnelingEnabled(z2).setMaxAudioChannelCount(i));
        }
    }

    public static final void m(VideoPlayerActivity videoPlayerActivity) {
        videoPlayerActivity.cs = false;
        AnimatorSet animatorSet = videoPlayerActivity.cr;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        videoPlayerActivity.cr = null;
        ImageView imageView = videoPlayerActivity.x;
        if (imageView == null) {
            cr4.n("loadingSpinner");
            throw null;
        }
        imageView.clearAnimation();
        FrameLayout frameLayout = videoPlayerActivity.t;
        if (frameLayout != null) {
            frameLayout.animate().alpha(0.0f).setDuration(300L).withEndAction(new sga(videoPlayerActivity, 7)).start();
        } else {
            cr4.n("loadingOverlay");
            throw null;
        }
    }

    public static final void n(VideoPlayerActivity videoPlayerActivity) {
        FrameLayout frameLayout = videoPlayerActivity.ba;
        if (frameLayout == null) {
            cr4.n("pauseOverlay");
            throw null;
        }
        if (frameLayout.getVisibility() == 8) {
            return;
        }
        FrameLayout frameLayout2 = videoPlayerActivity.ba;
        if (frameLayout2 == null) {
            cr4.n("pauseOverlay");
            throw null;
        }
        frameLayout2.animate().cancel();
        FrameLayout frameLayout3 = videoPlayerActivity.ba;
        if (frameLayout3 != null) {
            frameLayout3.animate().alpha(0.0f).setDuration(200L).withEndAction(new sga(videoPlayerActivity, 6)).start();
        } else {
            cr4.n("pauseOverlay");
            throw null;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x0048  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final void o(VideoPlayerActivity videoPlayerActivity) {
        VideoPlayerActivity videoPlayerActivity2;
        ContentItem contentItem;
        ExoPlayer exoPlayer;
        if (videoPlayerActivity.ck) {
            ExecutorService executorService = kq.a;
            kq.h("VideoPlayer", "Placeholder video ended — returning to sources (no scrobble/progress saved)");
            if (videoPlayerActivity.cf + 1 < videoPlayerActivity.ce.size()) {
                List list = ky8.a;
                ky8.c = videoPlayerActivity.cf + 1;
            }
            videoPlayerActivity.finish();
            return;
        }
        videoPlayerActivity.cb = true;
        List list2 = ky8.a;
        ky8.d = true;
        videoPlayerActivity.bq();
        if (!videoPlayerActivity.ck && (contentItem = videoPlayerActivity.bw) != null && (exoPlayer = videoPlayerActivity.bm) != null) {
            long duration = exoPlayer.getDuration();
            if (duration <= 0) {
                videoPlayerActivity2 = videoPlayerActivity;
            } else {
                videoPlayerActivity2 = videoPlayerActivity;
                wj0.c(androidx.lifecycle.s.a(videoPlayerActivity), null, null, new af(videoPlayerActivity2, contentItem, duration, (videoPlayerActivity.bx <= 0 || videoPlayerActivity.bz <= 0) ? null : contentItem.getTitle(), null), 3);
            }
        }
        boolean z = videoPlayerActivity2.r0;
        if (!z && videoPlayerActivity2.cc) {
            if (videoPlayerActivity2.o0 != null) {
                videoPlayerActivity2.bb();
                return;
            }
            ContentItem contentItem2 = videoPlayerActivity2.bw;
            if (contentItem2 == null) {
                videoPlayerActivity2.finish();
                return;
            }
            int tmdbId = contentItem2.getTmdbId();
            boolean z2 = mr8.a;
            mr8.a aVar = mr8.a ? (mr8.a) y41.af(mr8.d + 1, mr8.c) : null;
            if (aVar != null) {
                videoPlayerActivity2.o0 = new d(tmdbId, aVar.a, aVar.b, aVar.c, aVar.d, null);
                videoPlayerActivity2.bb();
                return;
            }
            mr8.a = false;
            mr8.b = 0;
            mr8.c = ik2.a;
            mr8.d = 0;
            videoPlayerActivity2.finish();
            return;
        }
        if (!z) {
            ContentItem contentItem3 = videoPlayerActivity2.bw;
            if ((contentItem3 != null ? contentItem3.getItemType() : null) == ContentItem.ItemType.TV_SHOW && videoPlayerActivity2.bx > 0 && videoPlayerActivity2.bz > 0 && videoPlayerActivity2.am().getAutoplayNextEpisode()) {
                if (videoPlayerActivity2.o0 != null) {
                    videoPlayerActivity2.bb();
                    return;
                }
                ContentItem contentItem4 = videoPlayerActivity2.bw;
                if (contentItem4 != null) {
                    wj0.c(androidx.lifecycle.s.a(videoPlayerActivity2), null, null, new y(videoPlayerActivity2, contentItem4.getTmdbId(), null), 3);
                    return;
                } else {
                    videoPlayerActivity2.finish();
                    return;
                }
            }
        }
        ContentItem contentItem5 = videoPlayerActivity2.bw;
        if ((contentItem5 != null ? contentItem5.getItemType() : null) == ContentItem.ItemType.MOVIE && videoPlayerActivity2.P && videoPlayerActivity2.am().getEnableRatingsPopupMovies()) {
            videoPlayerActivity2.bo();
        } else {
            videoPlayerActivity2.finish();
        }
    }

    public static final Long p(VideoPlayerActivity videoPlayerActivity, String str) {
        try {
            try {
                return Long.valueOf(ZonedDateTime.parse(str).toInstant().toEpochMilli());
            } catch (Exception unused) {
                return null;
            }
        } catch (Exception unused2) {
            return Long.valueOf(LocalDate.parse(n89.bb(10, str)).atTime(3, 0).atZone(ZoneId.of("America/New_York")).toInstant().toEpochMilli());
        }
    }

    public static final void q(VideoPlayerActivity videoPlayerActivity) {
        ContentItem contentItem;
        ExoPlayer exoPlayer;
        if (videoPlayerActivity.ck || !videoPlayerActivity.Q || (contentItem = videoPlayerActivity.bw) == null || (exoPlayer = videoPlayerActivity.bm) == null) {
            return;
        }
        long currentPosition = exoPlayer.getCurrentPosition();
        long duration = exoPlayer.getDuration();
        fx4 fx4Var = videoPlayerActivity.O;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        wj0.c(androidx.lifecycle.s.a(videoPlayerActivity), null, null, new ad(videoPlayerActivity, contentItem, currentPosition, duration, null), 3);
    }

    public static final void r(VideoPlayerActivity videoPlayerActivity) {
        FrameLayout frameLayout = videoPlayerActivity.t;
        if (frameLayout == null) {
            cr4.n("loadingOverlay");
            throw null;
        }
        if (frameLayout.getVisibility() != 0) {
            FrameLayout frameLayout2 = videoPlayerActivity.y;
            if (frameLayout2 == null) {
                cr4.n("errorOverlay");
                throw null;
            }
            if (frameLayout2.getVisibility() == 0) {
                return;
            }
            FrameLayout frameLayout3 = videoPlayerActivity.ba;
            if (frameLayout3 == null) {
                cr4.n("pauseOverlay");
                throw null;
            }
            frameLayout3.animate().cancel();
            FrameLayout frameLayout4 = videoPlayerActivity.ba;
            if (frameLayout4 == null) {
                cr4.n("pauseOverlay");
                throw null;
            }
            frameLayout4.setVisibility(0);
            FrameLayout frameLayout5 = videoPlayerActivity.ba;
            if (frameLayout5 == null) {
                cr4.n("pauseOverlay");
                throw null;
            }
            frameLayout5.setAlpha(0.0f);
            FrameLayout frameLayout6 = videoPlayerActivity.ba;
            if (frameLayout6 != null) {
                frameLayout6.animate().alpha(1.0f).setDuration(300L).start();
            } else {
                cr4.n("pauseOverlay");
                throw null;
            }
        }
    }

    public static final void s(VideoPlayerActivity videoPlayerActivity) {
        fx4 fx4Var = videoPlayerActivity.ct;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        videoPlayerActivity.J0 = -1L;
        videoPlayerActivity.K0 = 0;
        videoPlayerActivity.ct = wj0.c(androidx.lifecycle.s.a(videoPlayerActivity), null, null, new aq(videoPlayerActivity, null), 3);
    }

    public static final void t(VideoPlayerActivity videoPlayerActivity) {
        fx4 fx4Var = videoPlayerActivity.O;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        videoPlayerActivity.O = wj0.c(androidx.lifecycle.s.a(videoPlayerActivity), null, null, new ar(videoPlayerActivity, null), 3);
    }

    public static final void u(VideoPlayerActivity videoPlayerActivity) {
        ContentItem contentItem;
        if (videoPlayerActivity.ck || (contentItem = videoPlayerActivity.bw) == null) {
            return;
        }
        fx4 fx4Var = videoPlayerActivity.O;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        videoPlayerActivity.P = true;
        videoPlayerActivity.Q = false;
        wj0.c(androidx.lifecycle.s.a(videoPlayerActivity), null, null, new as(videoPlayerActivity, contentItem, null), 3);
    }

    public static final boolean v(VideoPlayerActivity videoPlayerActivity, long j) {
        return videoPlayerActivity.bs(j, true) || videoPlayerActivity.bs(j, false);
    }

    public static final void w(VideoPlayerActivity videoPlayerActivity) {
        ExoPlayer exoPlayer = videoPlayerActivity.bm;
        if (exoPlayer == null || exoPlayer.getDuration() <= 0) {
            return;
        }
        TextView textView = videoPlayerActivity.ai;
        if (textView == null) {
            cr4.n("timeTotal");
            throw null;
        }
        textView.setText(ak(exoPlayer.getDuration()));
        SeekBar seekBar = videoPlayerActivity.ak;
        if (seekBar != null) {
            seekBar.setMax(1000);
        } else {
            cr4.n("seekBar");
            throw null;
        }
    }

    public static final void x(VideoPlayerActivity videoPlayerActivity, boolean z) {
        ImageButton imageButton = videoPlayerActivity.al;
        if (imageButton == null) {
            cr4.n("btnPlayPause");
            throw null;
        }
        int i = R.drawable.ic_play;
        imageButton.setImageResource(z ? R.drawable.ic_pause : R.drawable.ic_play);
        ImageButton imageButton2 = videoPlayerActivity.aw;
        if (imageButton2 == null) {
            cr4.n("btnCenterPlayPause");
            throw null;
        }
        if (z) {
            i = R.drawable.ic_pause;
        }
        imageButton2.setImageResource(i);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static final void y(VideoPlayerActivity videoPlayerActivity, Tracks tracks) {
        t7a t7aVarListIterator = tracks.getGroups().listIterator(0);
        cr4.f(t7aVarListIterator, "iterator(...)");
        while (t7aVarListIterator.hasNext()) {
            Tracks.Group group = (Tracks.Group) t7aVarListIterator.next();
            int type = group.getType();
            if (type != 1 && type == 2) {
                int i = group.length;
            }
        }
    }

    public final void aa(com.strmr.ps.data.subtitle.t tVar) {
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer == null) {
            return;
        }
        this.T = tVar;
        if (tVar instanceof t.c) {
            this.f0 = false;
            TrackSelectionParameters trackSelectionParametersBuild = exoPlayer.getTrackSelectionParameters().buildUpon().setTrackTypeDisabled(3, true).build();
            cr4.f(trackSelectionParametersBuild, "build(...)");
            exoPlayer.setTrackSelectionParameters(trackSelectionParametersBuild);
            return;
        }
        if (!(tVar instanceof t.a)) {
            if (!(tVar instanceof t.b)) {
                throw new io6();
            }
            t.b bVar = (t.b) tVar;
            sb9 sb9Var = bVar.a;
            t.b.a aVar = bVar.b;
            MediaSource mediaSource = this.br;
            if (mediaSource == null) {
                Log.e("VideoPlayerActivity", "No original video source for subtitle merge");
                return;
            }
            DefaultDataSource.Factory factory = this.M0;
            if (factory == null) {
                Log.e("VideoPlayerActivity", "No data source factory available");
                return;
            } else {
                wj0.c(androidx.lifecycle.s.a(this), null, null, new m(this, sb9Var, aVar, factory, mediaSource, exoPlayer, null), 3);
                return;
            }
        }
        this.f0 = false;
        t.a aVar2 = (t.a) tVar;
        int i = aVar2.b;
        String str = aVar2.g;
        if (str != null && (n89.l(str, "pgs", true) || n89.l(str, "vobsub", true) || n89.l(str, "dvb", true))) {
            Toast.makeText(this, "PGS/VobSub subtitles cannot be styled. Select an external subtitle for customization.", 1).show();
        }
        Tracks currentTracks = exoPlayer.getCurrentTracks();
        cr4.f(currentTracks, "getCurrentTracks(...)");
        if (i >= currentTracks.getGroups().size()) {
            Log.e("VideoPlayerActivity", "Invalid groupIndex " + i + ", tracks.groups.size=" + currentTracks.getGroups().size());
            return;
        }
        Tracks.Group group = currentTracks.getGroups().get(i);
        if (group.getType() != 3) {
            Log.e("VideoPlayerActivity", n41.l("Track at groupIndex ", i, " is not a text track (type=", ")", group.getType()));
            return;
        }
        TrackSelectionParameters trackSelectionParametersBuild2 = exoPlayer.getTrackSelectionParameters().buildUpon().setTrackTypeDisabled(3, false).setOverrideForType(new TrackSelectionOverride(group.getMediaTrackGroup(), aVar2.a)).build();
        cr4.f(trackSelectionParametersBuild2, "build(...)");
        exoPlayer.setTrackSelectionParameters(trackSelectionParametersBuild2);
    }

    public final void ab() {
        SubtitleView subtitleView = this.s;
        if (subtitleView == null) {
            cr4.n("customSubtitleView");
            throw null;
        }
        subtitleView.setStyle(new CaptionStyleCompat(this.bo.getSubtitleColorValue(), this.bo.getSubtitleBackgroundColorValue(), 0, 1, -16777216, this.bo.getSubtitleTypeface(this)));
        float effectiveSubtitleTextSize = this.bo.getEffectiveSubtitleTextSize();
        SubtitleView subtitleView2 = this.s;
        if (subtitleView2 == null) {
            cr4.n("customSubtitleView");
            throw null;
        }
        subtitleView2.setFractionalTextSize(effectiveSubtitleTextSize);
        float effectiveSubtitlePositionFraction = this.bo.getEffectiveSubtitlePositionFraction();
        SubtitleView subtitleView3 = this.s;
        if (subtitleView3 != null) {
            subtitleView3.setBottomPaddingFraction(effectiveSubtitlePositionFraction);
        } else {
            cr4.n("customSubtitleView");
            throw null;
        }
    }

    public final void ac(float f) {
        float fB = zr7.b(f, 0.0f, 2.0f);
        if (fB <= 1.0f) {
            ExoPlayer exoPlayer = this.bm;
            if (exoPlayer != null) {
                exoPlayer.setVolume(fB);
            }
            try {
                LoudnessEnhancer loudnessEnhancer = this.m0;
                if (loudnessEnhancer != null) {
                    loudnessEnhancer.setEnabled(false);
                    return;
                }
                return;
            } catch (Exception e2) {
                n41.ab("LoudnessEnhancer disable failed: ", e2.getMessage(), "VideoPlayerActivity");
                this.m0 = null;
                return;
            }
        }
        ExoPlayer exoPlayer2 = this.bm;
        if (exoPlayer2 != null) {
            exoPlayer2.setVolume(1.0f);
        }
        int i = (int) ((fB - 1.0f) * 1500.0f);
        LoudnessEnhancer loudnessEnhancer2 = this.m0;
        if (loudnessEnhancer2 != null) {
            try {
                loudnessEnhancer2.setTargetGain(i);
                loudnessEnhancer2.setEnabled(true);
            } catch (Exception e3) {
                n41.ab("LoudnessEnhancer boost failed: ", e3.getMessage(), "VideoPlayerActivity");
                this.m0 = null;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x0041 A[PHI: r7
      0x0041: PHI (r7v5 int) = (r7v0 int), (r7v6 int) binds: [B:12:0x004a, B:9:0x003f] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final DefaultLoadControl ad() {
        int i;
        int i2;
        int i3;
        if (this.k0) {
            ExecutorService executorService = kq.a;
            kq.h("VideoPlayerActivity", "Bluetooth active — using larger audio buffers to prevent underruns");
            i = 2;
        } else {
            i = 1;
        }
        int minBufferMs = this.bo.getMinBufferMs() * i;
        int maxBufferMs = this.bo.getMaxBufferMs() * i;
        int bufferForPlaybackMs = this.bo.getBufferForPlaybackMs() * i;
        int bufferForPlaybackAfterRebufferMs = this.bo.getBufferForPlaybackAfterRebufferMs() * i;
        long jMaxMemory = Runtime.getRuntime().maxMemory();
        boolean z = this.F0;
        if (z) {
            i2 = (int) (jMaxMemory * 0.125d);
            i3 = 78643200;
            if (i2 > 78643200) {
                i2 = i3;
            }
        } else {
            i2 = (int) (jMaxMemory * 0.25d);
            i3 = 157286400;
            if (i2 > 157286400) {
            }
        }
        ExecutorService executorService2 = kq.a;
        StringBuilder sbR = vw2.r("Buffer config: targetBytes=", (i2 / 1024) / 1024, "MB, minBuffer=", "ms, maxBuffer=", minBufferMs);
        sbR.append(maxBufferMs);
        sbR.append("ms, reducedMode=");
        sbR.append(z);
        kq.h("VideoPlayerActivity", sbR.toString());
        DefaultLoadControl defaultLoadControlBuild = new DefaultLoadControl.Builder().setBufferDurationsMs(minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs).setTargetBufferBytes(i2).setPrioritizeTimeOverSizeThresholds(false).build();
        cr4.f(defaultLoadControlBuild, "build(...)");
        return defaultLoadControlBuild;
    }

    public final DefaultMediaSourceFactory ae() throws NoSuchAlgorithmException, KeyManagementException {
        kha khaVar = new kha();
        SSLContext sSLContext = SSLContext.getInstance("TLS");
        sSLContext.init(null, new TrustManager[]{khaVar}, new SecureRandom());
        OkHttpClient okHttpClientBuild = this.L0;
        if (okHttpClientBuild == null) {
            OkHttpClient.Builder builder = new OkHttpClient.Builder();
            SSLSocketFactory socketFactory = sSLContext.getSocketFactory();
            cr4.f(socketFactory, "getSocketFactory(...)");
            OkHttpClient.Builder builderHostnameVerifier = builder.sslSocketFactory(socketFactory, khaVar).hostnameVerifier(new vga());
            TimeUnit timeUnit = TimeUnit.SECONDS;
            okHttpClientBuild = builderHostnameVerifier.connectTimeout(15L, timeUnit).readTimeout(20L, timeUnit).connectionPool(new ConnectionPool(5, 5L, TimeUnit.MINUTES)).dns(new wf4()).retryOnConnectionFailure(true).followRedirects(true).followSslRedirects(true).addInterceptor(new iha()).addNetworkInterceptor(new jha(this)).build();
            this.L0 = okHttpClientBuild;
        }
        OkHttpDataSource.Factory userAgent = new OkHttpDataSource.Factory(okHttpClientBuild).setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36");
        cr4.f(userAgent, "setUserAgent(...)");
        this.N0 = userAgent;
        Map<String, String> map = this.bv;
        if (map != null) {
            userAgent.setDefaultRequestProperties(map);
        }
        this.M0 = new DefaultDataSource.Factory(this, new h48(userAgent));
        DefaultExtractorsFactory tsExtractorFlags = new DefaultExtractorsFactory().setTsExtractorTimestampSearchBytes(282000).setTsExtractorFlags(64);
        cr4.f(tsExtractorFlags, "setTsExtractorFlags(...)");
        DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory(this, new w18(tsExtractorFlags));
        DefaultDataSource.Factory factory = this.M0;
        cr4.d(factory);
        DefaultMediaSourceFactory defaultMediaSourceFactoryExperimentalParseSubtitlesDuringExtraction = defaultMediaSourceFactory.setDataSourceFactory(factory).setLoadErrorHandlingPolicy((LoadErrorHandlingPolicy) new hha()).experimentalParseSubtitlesDuringExtraction(false);
        cr4.f(defaultMediaSourceFactoryExperimentalParseSubtitlesDuringExtraction, "experimentalParseSubtitlesDuringExtraction(...)");
        return defaultMediaSourceFactoryExperimentalParseSubtitlesDuringExtraction;
    }

    public final gha af() {
        boolean z = this.G0 || ax();
        boolean z2 = !am().getAudioPassthrough();
        if (z && !this.G0) {
            ExecutorService executorService = kq.a;
            kq.h("VideoPlayerActivity", "Bluetooth audio detected — forcing stereo AudioSink");
        }
        gha ghaVar = new gha(this, z, this, z2);
        ghaVar.setExtensionRendererMode((this.H0 || this.bo.isSoftwarePreferred()) ? 2 : 1);
        ghaVar.setEnableDecoderFallback(true);
        ghaVar.setMapDV7ToHevc(true);
        return ghaVar;
    }

    public final DefaultTrackSelector ag() {
        boolean audioPassthrough = am().getAudioPassthrough();
        ExecutorService executorService = kq.a;
        kq.h("VideoPlayerActivity", "Audio passthrough enabled: " + audioPassthrough);
        String defaultAudioLanguage = this.bo.getDefaultAudioLanguage();
        if (defaultAudioLanguage == null) {
            defaultAudioLanguage = "en";
        }
        String defaultSubtitleLanguage = this.bo.getDefaultSubtitleLanguage();
        ArrayList arrayList = new ArrayList();
        MediaCodecInfo[] codecInfos = new MediaCodecList(1).getCodecInfos();
        for (Map.Entry entry : wo5.j(new q07(MimeTypes.AUDIO_E_AC3, "EAC3"), new q07(MimeTypes.AUDIO_AC3, RtpPayloadFormat.RTP_MEDIA_AC3), new q07(MimeTypes.AUDIO_E_AC3_JOC, "EAC3-JOC"), new q07(MimeTypes.AUDIO_AC4, "AC4"), new q07(MimeTypes.AUDIO_DTS, "DTS"), new q07(MimeTypes.AUDIO_DTS_HD, "DTS-HD")).entrySet()) {
            String str = (String) entry.getKey();
            String str2 = (String) entry.getValue();
            cr4.d(codecInfos);
            int length = codecInfos.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    arrayList.add(str);
                    ExecutorService executorService2 = kq.a;
                    kq.h("VideoPlayerActivity", n41.o("No decoder for ", str2, " (", str, ")"));
                    break;
                }
                MediaCodecInfo mediaCodecInfo = codecInfos[i];
                if (!mediaCodecInfo.isEncoder()) {
                    String[] supportedTypes = mediaCodecInfo.getSupportedTypes();
                    cr4.f(supportedTypes, "getSupportedTypes(...)");
                    for (String str3 : supportedTypes) {
                        if (n89.u(str3, str)) {
                            break;
                        }
                    }
                }
                i++;
            }
        }
        ExecutorService executorService3 = kq.a;
        kq.h("VideoPlayerActivity", "Unsupported audio codecs: " + arrayList);
        boolean zAx = ax();
        boolean z = this.bo.getTunnelingEnabled() && !zAx;
        if (this.bo.getTunnelingEnabled() && !z) {
            kq.h("VideoPlayerActivity", "Bluetooth audio detected — disabling tunneling to prevent audio dropouts");
        }
        boolean z2 = audioPassthrough && !zAx;
        if (audioPassthrough && !z2) {
            kq.h("VideoPlayerActivity", "Bluetooth audio detected — forcing stereo PCM output (passthrough disabled)");
        }
        DefaultTrackSelector defaultTrackSelector = new DefaultTrackSelector(this);
        DefaultTrackSelector.Parameters.Builder exceedRendererCapabilitiesIfNecessary = defaultTrackSelector.buildUponParameters().setTunnelingEnabled(z).setMaxVideoSize(3840, 2160).setMaxVideoFrameRate(60).setAllowAudioMixedMimeTypeAdaptiveness(true).setExceedAudioConstraintsIfNecessary(true).setExceedRendererCapabilitiesIfNecessary(true);
        cr4.f(exceedRendererCapabilitiesIfNecessary, "setExceedRendererCapabilitiesIfNecessary(...)");
        if (defaultAudioLanguage.length() != 0) {
            exceedRendererCapabilitiesIfNecessary.setPreferredAudioLanguage(defaultAudioLanguage);
        }
        if (!this.bo.getSubtitlesEnabledByDefault()) {
            exceedRendererCapabilitiesIfNecessary.setTrackTypeDisabled(3, true);
            if (defaultSubtitleLanguage != null && defaultSubtitleLanguage.length() != 0) {
                exceedRendererCapabilitiesIfNecessary.setPreferredTextLanguage(defaultSubtitleLanguage);
            }
        } else if (defaultSubtitleLanguage != null && defaultSubtitleLanguage.length() != 0) {
            exceedRendererCapabilitiesIfNecessary.setPreferredTextLanguage(defaultSubtitleLanguage);
        }
        if (zAx || this.G0) {
            exceedRendererCapabilitiesIfNecessary.setMaxAudioChannelCount(2);
            kq.h("VideoPlayerActivity", this.G0 ? "Stereo recovery — audio limited to 2 channels" : "Bluetooth active — audio limited to stereo PCM");
        } else {
            exceedRendererCapabilitiesIfNecessary.setMaxAudioChannelCount(Integer.MAX_VALUE);
            kq.h("VideoPlayerActivity", z2 ? "Audio passthrough enabled (surround supported)" : "Audio multichannel PCM (device handles downmix)");
        }
        if (!arrayList.isEmpty() && !z2) {
            exceedRendererCapabilitiesIfNecessary.setPreferredAudioMimeTypes(MimeTypes.AUDIO_AAC, MimeTypes.AUDIO_MPEG, MimeTypes.AUDIO_OPUS, MimeTypes.AUDIO_VORBIS);
            kq.h("VideoPlayerActivity", "Passthrough disabled — preferring universal audio codecs, unsupported: " + y41.ai(arrayList, null, null, null, null, 63));
        }
        defaultTrackSelector.setParameters(exceedRendererCapabilitiesIfNecessary.build());
        return defaultTrackSelector;
    }

    public final MediaSource ah(MediaItem mediaItem, String str) {
        DefaultDataSource.Factory factory = this.M0;
        if (factory == null) {
            DefaultMediaSourceFactory defaultMediaSourceFactory = this.bp;
            cr4.d(defaultMediaSourceFactory);
            MediaSource mediaSourceCreateMediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
            cr4.f(mediaSourceCreateMediaSource, "createMediaSource(...)");
            return mediaSourceCreateMediaSource;
        }
        String lowerCase = str.toLowerCase(Locale.ROOT);
        cr4.f(lowerCase, "toLowerCase(...)");
        if (n89.l(lowerCase, ".m3u8", false) || n89.l(lowerCase, "/hls", false)) {
            HlsMediaSource hlsMediaSourceCreateMediaSource = new HlsMediaSource.Factory(factory).setAllowChunklessPreparation(true).createMediaSource(mediaItem);
            cr4.d(hlsMediaSourceCreateMediaSource);
            return hlsMediaSourceCreateMediaSource;
        }
        if (n89.l(lowerCase, ".mpd", false) || n89.l(lowerCase, "/dash", false)) {
            DashMediaSource dashMediaSourceCreateMediaSource = new DashMediaSource.Factory(factory).createMediaSource(mediaItem);
            cr4.d(dashMediaSourceCreateMediaSource);
            return dashMediaSourceCreateMediaSource;
        }
        DefaultMediaSourceFactory defaultMediaSourceFactory2 = this.bp;
        cr4.d(defaultMediaSourceFactory2);
        MediaSource mediaSourceCreateMediaSource2 = defaultMediaSourceFactory2.createMediaSource(mediaItem);
        cr4.f(mediaSourceCreateMediaSource2, "createMediaSource(...)");
        return mediaSourceCreateMediaSource2;
    }

    public final void ai(long j, long j2) {
        this.B = j;
        if (j2 > 0) {
            SeekBar seekBar = this.ak;
            if (seekBar == null) {
                cr4.n("seekBar");
                throw null;
            }
            seekBar.setProgress((int) ((((long) 1000) * j) / j2));
            TextView textView = this.ah;
            if (textView == null) {
                cr4.n("timeCurrent");
                throw null;
            }
            textView.setText(ak(j));
        }
        bk();
        Handler handler = this.cq;
        sga sgaVar = this.C;
        handler.removeCallbacks(sgaVar);
        handler.postDelayed(sgaVar, 300L);
    }

    public final void aj() throws Throwable {
        fx4 fx4Var = this.cy;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        this.cq.removeCallbacks(this.C);
        long j = this.B;
        if (j >= 0) {
            ExoPlayer exoPlayer = this.bm;
            if (exoPlayer != null) {
                exoPlayer.seekTo(j);
            }
            this.B = -1L;
        }
        ExoPlayer exoPlayer2 = this.bm;
        if (exoPlayer2 != null) {
            long duration = exoPlayer2.getDuration();
            if (duration > 0) {
                this.cd = exoPlayer2.getCurrentPosition() / duration;
            }
        }
        bf(true);
        if (this.P) {
            bq();
            this.P = false;
            this.Q = false;
        }
        ExoPlayer exoPlayer3 = this.bm;
        if (exoPlayer3 != null) {
            exoPlayer3.setPlayWhenReady(false);
            try {
                exoPlayer3.stop();
            } catch (Exception unused) {
            }
        }
        e17 e17Var = StrmrApp.w;
        e17 e17Var2 = StrmrApp.w;
        if (e17Var2 != null) {
            e17Var2.b(this.bs);
        }
        if (this.cd >= 0.9d) {
            ContentItem contentItem = this.bw;
            if ((contentItem != null ? contentItem.getItemType() : null) == ContentItem.ItemType.MOVIE && this.P && am().getEnableRatingsPopupMovies()) {
                this.cb = true;
                List list = ky8.a;
                ky8.d = true;
                bo();
                return;
            }
        }
        if (this.cd >= 0.9d) {
            this.cb = true;
            List list2 = ky8.a;
            ky8.d = true;
        }
        finish();
    }

    public final PlayerSettingsRepository al() {
        PlayerSettingsRepository playerSettingsRepository = this.f;
        if (playerSettingsRepository != null) {
            return playerSettingsRepository;
        }
        cr4.n("playerSettingsRepository");
        throw null;
    }

    public final PreferencesRepository am() {
        PreferencesRepository preferencesRepository = this.i;
        if (preferencesRepository != null) {
            return preferencesRepository;
        }
        cr4.n("preferencesRepository");
        throw null;
    }

    public final String an(String str) throws UnsupportedEncodingException {
        String str2;
        if (!this.bo.getProxyEnabled()) {
            return str;
        }
        String lowerCase = str.toLowerCase(Locale.ROOT);
        cr4.f(lowerCase, "toLowerCase(...)");
        if (!n89.r(lowerCase, ".m3u8", false) && !n89.r(lowerCase, ".mpd", false) && !n89.l(lowerCase, "/manifest", false) && !n89.ar(lowerCase, "file://", false) && n89.ar(lowerCase, "http", false)) {
            e17 e17Var = StrmrApp.w;
            e17 e17Var2 = StrmrApp.w;
            if (e17Var2 != null) {
                if (e17Var2.d) {
                    String strEncode = URLEncoder.encode(str, "UTF-8");
                    str2 = "http://127.0.0.1:" + e17Var2.getListeningPort() + "/stream?url=" + strEncode;
                } else {
                    str2 = null;
                }
                if (str2 != null) {
                    return str2;
                }
            }
        }
        return str;
    }

    public final long ap(boolean z) {
        return getPackageManager().hasSystemFeature("android.software.leanback") ? this.bo.getTvKeySeekMs() : z ? this.bo.getForwardSeekMs() : this.bo.getRewindSeekMs();
    }

    public final SubtitleManager aq() {
        SubtitleManager subtitleManager = this.k;
        if (subtitleManager != null) {
            return subtitleManager;
        }
        cr4.n("subtitleManager");
        throw null;
    }

    public final TMDBApiService ar() {
        TMDBApiService tMDBApiService = this.n;
        if (tMDBApiService != null) {
            return tMDBApiService;
        }
        cr4.n("tmdbApiService");
        throw null;
    }

    public final void at() {
        if (this.D) {
            this.D = false;
            LinearLayout linearLayout = this.ad;
            if (linearLayout == null) {
                cr4.n("topBar");
                throw null;
            }
            linearLayout.animate().alpha(0.0f).setDuration(200L).withEndAction(new sga(this, 2)).start();
            LinearLayout linearLayout2 = this.ae;
            if (linearLayout2 == null) {
                cr4.n("bottomControls");
                throw null;
            }
            linearLayout2.animate().alpha(0.0f).setDuration(200L).withEndAction(new sga(this, 3)).start();
            if (this.az) {
                LinearLayout linearLayout3 = this.av;
                if (linearLayout3 != null) {
                    linearLayout3.animate().alpha(0.0f).setDuration(200L).withEndAction(new sga(this, 4)).start();
                } else {
                    cr4.n("centerControls");
                    throw null;
                }
            }
        }
    }

    @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper
    public final void attachBaseContext(Context context) {
        cr4.g(context, "newBase");
        super.attachBaseContext(hf5.a(context));
    }

    public final void au() {
        fx4 fx4Var = this.s0;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        this.s0 = null;
        CardView cardView = this.bf;
        if (cardView == null) {
            cr4.n("nextEpisodeOverlay");
            throw null;
        }
        cardView.setVisibility(8);
        this.q0 = false;
    }

    public final void av() {
        if (this.M) {
            fx4 fx4Var = this.L;
            if (fx4Var != null) {
                ((rx4) fx4Var).h(null);
            }
            FrameLayout frameLayout = this.F;
            if (frameLayout == null) {
                cr4.n("skipIntroContainer");
                throw null;
            }
            frameLayout.animate().alpha(0.0f).setDuration(200L).withEndAction(new sga(this, 1)).start();
            this.M = false;
        }
    }

    public final void aw() {
        if (Build.VERSION.SDK_INT < 30) {
            getWindow().getDecorView().setSystemUiVisibility(5894);
            return;
        }
        WindowInsetsController insetsController = getWindow().getInsetsController();
        if (insetsController != null) {
            insetsController.hide(WindowInsets.Type.systemBars());
            insetsController.setSystemBarsBehavior(2);
        }
    }

    public final boolean ax() {
        AudioManager audioManager = this.h0;
        if (audioManager == null) {
            cr4.n("audioManager");
            throw null;
        }
        if (audioManager.isBluetoothA2dpOn()) {
            return true;
        }
        AudioManager audioManager2 = this.h0;
        if (audioManager2 == null) {
            cr4.n("audioManager");
            throw null;
        }
        AudioDeviceInfo[] devices = audioManager2.getDevices(2);
        cr4.d(devices);
        for (AudioDeviceInfo audioDeviceInfo : devices) {
            if (Build.VERSION.SDK_INT >= 31 && (audioDeviceInfo.getType() == 26 || audioDeviceInfo.getType() == 27)) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Type inference failed for: r1v4, types: [java.lang.Object, java.util.Map] */
    public final boolean ay(String str, String str2) {
        if (str != null && str.length() != 0) {
            Locale locale = Locale.ROOT;
            String lowerCase = str.toLowerCase(locale);
            cr4.f(lowerCase, "toLowerCase(...)");
            String strBb = n89.bb(3, lowerCase);
            String lowerCase2 = str2.toLowerCase(locale);
            cr4.f(lowerCase2, "toLowerCase(...)");
            if (strBb.equals(lowerCase2) || n89.ar(strBb, lowerCase2, false)) {
                return true;
            }
            List list = (List) this.O0.get(lowerCase2);
            if (list != null) {
                List<String> list2 = list;
                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                    for (String str3 : list2) {
                        if (strBb.equals(str3) || n89.ar(strBb, str3, false)) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    public final void az() {
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer == null) {
            return;
        }
        fx4 fx4Var = this.U;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        this.V = true;
        this.U = wj0.c(androidx.lifecycle.s.a(this), null, null, new v(exoPlayer, this, null), 3);
    }

    public final void ba(int i, int i2) {
        ContentItem contentItem = this.bw;
        if (contentItem == null) {
            return;
        }
        Intent intent = new Intent(this, (Class<?>) SourcesActivity.class);
        intent.putExtra("content_item", contentItem);
        intent.putExtra("season", i);
        intent.putExtra(PlaybackProgress.TYPE_EPISODE, i2);
        intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
        startActivity(intent);
        finish();
    }

    public final void bb() {
        d dVar;
        if (this.r0 || (dVar = this.o0) == null) {
            return;
        }
        this.r0 = true;
        au();
        if (!this.cc) {
            wj0.c(androidx.lifecycle.s.a(this), null, null, new z(this, dVar, null), 3);
            return;
        }
        mr8.a aVarA = mr8.a();
        if (aVarA == null) {
            mr8.a = false;
            mr8.b = 0;
            mr8.c = ik2.a;
            mr8.d = 0;
            finish();
            return;
        }
        ContentItem contentItem = this.bw;
        if (contentItem == null) {
            return;
        }
        Intent intent = new Intent(this, (Class<?>) SourcesActivity.class);
        intent.putExtra("content_item", contentItem);
        intent.putExtra("season", aVarA.a);
        intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
        intent.putExtra("preferred_binge_group", this.ci);
        intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
        startActivity(intent);
        finish();
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    public final void bc(long j) throws NoSuchAlgorithmException, KeyManagementException {
        this.u0 = false;
        this.v0 = false;
        gha ghaVarAf = af();
        DefaultTrackSelector defaultTrackSelectorAg = ag();
        DefaultLoadControl defaultLoadControlAd = ad();
        DefaultMediaSourceFactory defaultMediaSourceFactoryAe = ae();
        this.bp = defaultMediaSourceFactoryAe;
        ExoPlayer exoPlayerBuild = new ExoPlayer.Builder(this).setRenderersFactory(ghaVarAf).setTrackSelector(defaultTrackSelectorAg).setLoadControl(defaultLoadControlAd).setMediaSourceFactory(defaultMediaSourceFactoryAe).setAudioAttributes(new AudioAttributes.Builder().setUsage(1).setContentType(3).build(), false).setWakeMode(2).build();
        cr4.f(exoPlayerBuild, "build(...)");
        int i = this.n0;
        if (i != 0) {
            exoPlayerBuild.setAudioSessionId(i);
        }
        bi(this.n0);
        PlayerView playerView = this.r;
        if (playerView == null) {
            cr4.n("playerView");
            throw null;
        }
        playerView.setPlayer(exoPlayerBuild);
        this.bm = exoPlayerBuild;
        if (this.be != 1.0f) {
            exoPlayerBuild.setPlaybackParameters(new PlaybackParameters(this.be));
        }
        SubtitleView subtitleView = this.s;
        if (subtitleView == null) {
            cr4.n("customSubtitleView");
            throw null;
        }
        c cVar = new c(this, subtitleView);
        this.g0 = cVar;
        exoPlayerBuild.addListener(cVar);
        exoPlayerBuild.addAnalyticsListener(new cha(this, exoPlayerBuild));
        MediaSession mediaSession = this.bn;
        if (mediaSession != null) {
            mediaSession.setPlayer(exoPlayerBuild);
        }
        exoPlayerBuild.addListener(new mha(this, exoPlayerBuild));
        MediaItem mediaItemBuild = new MediaItem.Builder().setUri(an(this.bs)).build();
        cr4.f(mediaItemBuild, "build(...)");
        MediaSource mediaSourceAh = ah(mediaItemBuild, this.bs);
        this.bq = mediaSourceAh;
        this.br = mediaSourceAh;
        exoPlayerBuild.setMediaSource(mediaSourceAh);
        exoPlayerBuild.seekTo(j);
        exoPlayerBuild.prepare();
        exoPlayerBuild.setPlayWhenReady(true);
        ExecutorService executorService = kq.a;
        kq.h("VideoPlayerActivity", "Recovery rebuild complete, resuming from " + j + "ms (reducedBuffer=" + this.F0 + ")");
    }

    public final void bd() {
        try {
            LoudnessEnhancer loudnessEnhancer = this.m0;
            if (loudnessEnhancer != null) {
                loudnessEnhancer.release();
            }
        } catch (Exception e2) {
            n41.ab("Error releasing volume boost: ", e2.getMessage(), "VideoPlayerActivity");
        }
        this.m0 = null;
    }

    public final void be() {
        Handler handler = this.cq;
        sga sgaVar = this.E;
        handler.removeCallbacks(sgaVar);
        handler.postDelayed(sgaVar, 5000L);
    }

    public final void bf(boolean z) throws Throwable {
        ContentItem contentItem;
        ExoPlayer exoPlayer;
        String scraperId;
        String infoHash;
        if (this.ck || (contentItem = this.bw) == null || (exoPlayer = this.bm) == null) {
            return;
        }
        long currentPosition = exoPlayer.getCurrentPosition();
        long duration = exoPlayer.getDuration();
        if (duration <= 0 || currentPosition < 5000) {
            return;
        }
        String title = (this.bx <= 0 || this.bz <= 0) ? null : contentItem.getTitle();
        StreamInfo streamInfo = (StreamInfo) y41.af(this.cf, this.ce);
        String str = (streamInfo == null || (infoHash = streamInfo.getInfoHash()) == null || n89.ab(infoHash)) ? null : infoHash;
        String str2 = (streamInfo == null || (scraperId = streamInfo.getScraperId()) == null || n89.ab(scraperId)) ? null : scraperId;
        String bingeGroup = streamInfo != null ? streamInfo.getBingeGroup() : null;
        if (z) {
            wj0.d(ak2.a, new ah(this, contentItem, currentPosition, duration, title, str, str2, bingeGroup, null));
        } else {
            wj0.c(androidx.lifecycle.s.a(this), null, null, new ai(this, contentItem, currentPosition, duration, title, str, str2, bingeGroup, null), 3);
        }
    }

    public final void bg() {
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer != null) {
            long jAp = ap(false);
            long currentPosition = this.B;
            if (currentPosition < 0) {
                currentPosition = exoPlayer.getCurrentPosition();
            }
            long j = currentPosition - jAp;
            ai(j >= 0 ? j : 0L, exoPlayer.getDuration());
        }
    }

    public final void bh() {
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer != null) {
            long jAp = ap(true);
            long currentPosition = this.B;
            if (currentPosition < 0) {
                currentPosition = exoPlayer.getCurrentPosition();
            }
            long j = currentPosition + jAp;
            long duration = exoPlayer.getDuration();
            if (j > duration) {
                j = duration;
            }
            ai(j, exoPlayer.getDuration());
        }
    }

    public final void bi(int i) {
        bd();
        am().getVolumeMultiplier();
        if (i == 0) {
            Log.w("VideoPlayerActivity", "Cannot initialize volume boost: invalid audio session ID (" + i + ")");
            return;
        }
        try {
            this.m0 = new LoudnessEnhancer(i);
            new StringBuilder("LoudnessEnhancer initialized for session ").append(i);
        } catch (Exception e2) {
            Log.e("VideoPlayerActivity", "Failed to initialize LoudnessEnhancer: " + e2.getMessage(), e2);
            this.m0 = null;
        }
    }

    public final void bj(String str) {
        TextView textView = this.aa;
        if (textView == null) {
            cr4.n("skipIndicator");
            throw null;
        }
        textView.setText(str);
        TextView textView2 = this.aa;
        if (textView2 == null) {
            cr4.n("skipIndicator");
            throw null;
        }
        textView2.setVisibility(0);
        TextView textView3 = this.aa;
        if (textView3 == null) {
            cr4.n("skipIndicator");
            throw null;
        }
        textView3.setAlpha(1.0f);
        TextView textView4 = this.aa;
        if (textView4 != null) {
            textView4.animate().alpha(0.0f).setStartDelay(1000L).setDuration(300L).withEndAction(new sga(this, 8)).start();
        } else {
            cr4.n("skipIndicator");
            throw null;
        }
    }

    public final void bk() {
        if (this.D) {
            be();
            return;
        }
        this.D = true;
        LinearLayout linearLayout = this.ad;
        if (linearLayout == null) {
            cr4.n("topBar");
            throw null;
        }
        linearLayout.setVisibility(0);
        LinearLayout linearLayout2 = this.ae;
        if (linearLayout2 == null) {
            cr4.n("bottomControls");
            throw null;
        }
        linearLayout2.setVisibility(0);
        LinearLayout linearLayout3 = this.ad;
        if (linearLayout3 == null) {
            cr4.n("topBar");
            throw null;
        }
        linearLayout3.setAlpha(0.0f);
        LinearLayout linearLayout4 = this.ae;
        if (linearLayout4 == null) {
            cr4.n("bottomControls");
            throw null;
        }
        linearLayout4.setAlpha(0.0f);
        LinearLayout linearLayout5 = this.ad;
        if (linearLayout5 == null) {
            cr4.n("topBar");
            throw null;
        }
        linearLayout5.animate().alpha(1.0f).setDuration(200L).start();
        LinearLayout linearLayout6 = this.ae;
        if (linearLayout6 == null) {
            cr4.n("bottomControls");
            throw null;
        }
        linearLayout6.animate().alpha(1.0f).setDuration(200L).withEndAction(new sga(this, 5)).start();
        if (this.az) {
            LinearLayout linearLayout7 = this.av;
            if (linearLayout7 == null) {
                cr4.n("centerControls");
                throw null;
            }
            linearLayout7.setVisibility(0);
            LinearLayout linearLayout8 = this.av;
            if (linearLayout8 == null) {
                cr4.n("centerControls");
                throw null;
            }
            linearLayout8.setAlpha(0.0f);
            LinearLayout linearLayout9 = this.av;
            if (linearLayout9 == null) {
                cr4.n("centerControls");
                throw null;
            }
            linearLayout9.animate().alpha(1.0f).setDuration(200L).start();
        }
        be();
    }

    public final void bl(String str) {
        this.cs = false;
        AnimatorSet animatorSet = this.cr;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        this.cr = null;
        FrameLayout frameLayout = this.t;
        if (frameLayout == null) {
            cr4.n("loadingOverlay");
            throw null;
        }
        frameLayout.setVisibility(8);
        FrameLayout frameLayout2 = this.y;
        if (frameLayout2 == null) {
            cr4.n("errorOverlay");
            throw null;
        }
        frameLayout2.setVisibility(0);
        TextView textView = this.z;
        if (textView != null) {
            textView.setText(str);
        } else {
            cr4.n("errorMessage");
            throw null;
        }
    }

    public final String bm() {
        String title;
        ContentItem contentItem = this.bw;
        if (contentItem == null || (title = contentItem.getTitle()) == null) {
            title = this.bt;
        }
        return n89.bg(new pw7("\\s*-?\\s*S\\d+E\\d+.*$").f("", title)).toString();
    }

    public final void bn() {
        d dVar = this.o0;
        if (dVar == null) {
            return;
        }
        int i = dVar.c;
        int i2 = dVar.b;
        if (this.M) {
            av();
        }
        TextView textView = this.bh;
        if (textView == null) {
            cr4.n("nextEpisodeLabel");
            throw null;
        }
        textView.setText(this.cc ? vw2.i(i2, i, "Shuffle · S", "E") : vw2.i(i2, i, "S", "E"));
        TextView textView2 = this.bi;
        if (textView2 == null) {
            cr4.n("nextEpisodeTitle");
            throw null;
        }
        String str = dVar.d;
        if (str == null) {
            str = "";
        }
        textView2.setText(str);
        String str2 = dVar.e;
        if (str2 != null) {
            l08 l08Var = (l08) ((l08) com.bumptech.glide.a.c(this).e(this).n(str2).l(R.drawable.default_background)).f(R.drawable.default_background);
            ImageView imageView = this.bg;
            if (imageView == null) {
                cr4.n("nextEpisodeThumbnail");
                throw null;
            }
            l08Var.ah(imageView);
        }
        CardView cardView = this.bf;
        if (cardView == null) {
            cr4.n("nextEpisodeOverlay");
            throw null;
        }
        cardView.setVisibility(0);
        this.q0 = true;
        Button button = this.bk;
        if (button == null) {
            cr4.n("btnPlayNext");
            throw null;
        }
        button.requestFocus();
        this.t0 = 30;
        fx4 fx4Var = this.s0;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        this.s0 = wj0.c(androidx.lifecycle.s.a(this), null, null, new am(this, null), 3);
    }

    public final void bo() {
        if (isFinishing() || isDestroyed()) {
            return;
        }
        ContentItem contentItem = this.bw;
        if (contentItem == null) {
            finish();
        } else {
            wj0.c(androidx.lifecycle.s.a(this), null, null, new ak(this, contentItem, null), 3);
        }
    }

    public final void bq() {
        ContentItem contentItem;
        ExoPlayer exoPlayer;
        fx4 fx4Var = this.O;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        if (this.ck || (contentItem = this.bw) == null || (exoPlayer = this.bm) == null) {
            return;
        }
        long currentPosition = exoPlayer.getCurrentPosition();
        long duration = exoPlayer.getDuration();
        m12 m12Var = sc2.a;
        wj0.c(bk1.a(m02.c), null, null, new au(this, contentItem, currentPosition, duration, null), 3);
    }

    public final boolean bs(long j, boolean z) {
        String directUrl;
        String host;
        int size = this.ce.size();
        for (int i = this.cf + 1; i < size; i++) {
            StreamInfo streamInfo = (StreamInfo) this.ce.get(i);
            if (streamInfo.isDirectUrl() && (directUrl = streamInfo.getDirectUrl()) != null && !n89.ab(directUrl)) {
                if (z && !this.ch.isEmpty()) {
                    try {
                        host = Uri.parse(streamInfo.getDirectUrl()).getHost();
                    } catch (Exception unused) {
                        host = null;
                    }
                    if (host != null && this.ch.contains(host)) {
                        ExecutorService executorService = kq.a;
                        kq.h("VideoPlayer", "Skipping source " + i + " — host " + host + " blacklisted");
                    }
                }
                ExecutorService executorService2 = kq.a;
                int size2 = this.ce.size();
                String strBb = n89.bb(40, streamInfo.getFileName());
                StringBuilder sbR = vw2.r("Auto-switching to source ", i, DomExceptionUtils.SEPARATOR, ": ", size2);
                sbR.append(strBb);
                kq.h("VideoPlayer", sbR.toString());
                Toast.makeText(this, "Source failed — trying next (" + this.cg + "/5)", 0).show();
                e17 e17Var = StrmrApp.w;
                e17 e17Var2 = StrmrApp.w;
                if (e17Var2 != null) {
                    e17Var2.b(this.bs);
                }
                ExoPlayer exoPlayer = this.bm;
                if (exoPlayer != null) {
                    try {
                        exoPlayer.stop();
                        exoPlayer.clearMediaItems();
                    } catch (Exception unused2) {
                    }
                }
                this.cf = i;
                String directUrl2 = streamInfo.getDirectUrl();
                cr4.d(directUrl2);
                this.bs = directUrl2;
                this.bv = streamInfo.getProxyHeaders();
                OkHttpDataSource.Factory factory = this.N0;
                if (factory != null) {
                    Map<String, String> proxyHeaders = streamInfo.getProxyHeaders();
                    if (proxyHeaders == null) {
                        proxyHeaders = jk2.a;
                    }
                    factory.setDefaultRequestProperties(proxyHeaders);
                }
                this.cn = System.currentTimeMillis();
                this.z0 = false;
                this.A0 = false;
                this.B0 = 0;
                this.I0 = false;
                this.C0 = false;
                this.D0 = 0;
                this.H0 = false;
                this.cj = false;
                this.ck = false;
                this.cm = false;
                this.cl = null;
                ExoPlayer exoPlayer2 = this.bm;
                if (exoPlayer2 != null) {
                    MediaItem mediaItemBuild = new MediaItem.Builder().setUri(an(this.bs)).build();
                    cr4.f(mediaItemBuild, "build(...)");
                    MediaSource mediaSourceAh = ah(mediaItemBuild, this.bs);
                    this.bq = mediaSourceAh;
                    this.br = mediaSourceAh;
                    exoPlayer2.setMediaSource(mediaSourceAh);
                    if (j > 0) {
                        exoPlayer2.seekTo(j);
                    }
                    exoPlayer2.prepare();
                    exoPlayer2.setPlayWhenReady(true);
                }
                return true;
            }
        }
        return false;
    }

    public final void bt() {
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer != null) {
            if (exoPlayer.isPlaying()) {
                exoPlayer.pause();
            } else {
                exoPlayer.play();
            }
        }
    }

    @Override // defpackage.n91, android.app.Activity, android.view.Window.Callback
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        com.strmr.ps.ui.player.a aVar;
        cr4.g(keyEvent, "event");
        if (this.az && keyEvent.getAction() == 0 && !this.q0 && ((aVar = this.Z) == null || !aVar.o)) {
            int keyCode = keyEvent.getKeyCode();
            if (keyCode == 62 || keyCode == 85 || keyCode == 126 || keyCode == 127) {
                bt();
                if (this.D) {
                    be();
                    return true;
                }
                bk();
                return true;
            }
            switch (keyCode) {
                case 19:
                    AudioManager audioManager = this.h0;
                    if (audioManager != null) {
                        audioManager.adjustStreamVolume(3, 1, 1);
                        return true;
                    }
                    cr4.n("audioManager");
                    throw null;
                case 20:
                    AudioManager audioManager2 = this.h0;
                    if (audioManager2 != null) {
                        audioManager2.adjustStreamVolume(3, -1, 1);
                        return true;
                    }
                    cr4.n("audioManager");
                    throw null;
                case 21:
                    bg();
                    return true;
                case 22:
                    bh();
                    return true;
            }
        }
        return super.dispatchKeyEvent(keyEvent);
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x0191  */
    @Override // defpackage.o74, androidx.fragment.app.t, defpackage.j91, defpackage.n91, android.app.Activity
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onCreate(Bundle bundle) {
        mr8.a aVarB;
        int i;
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        int i7;
        int size;
        super.onCreate(bundle);
        ql9.a(this);
        setContentView(R.layout.activity_video_player);
        Object systemService = getSystemService("audio");
        cr4.e(systemService, "null cannot be cast to non-null type android.media.AudioManager");
        this.h0 = (AudioManager) systemService;
        this.k0 = ax();
        oha ohaVar = new oha(this);
        this.l0 = ohaVar;
        AudioManager audioManager = this.h0;
        if (audioManager == null) {
            cr4.n("audioManager");
            throw null;
        }
        audioManager.registerAudioDeviceCallback(ohaVar, this.cq);
        aw();
        final int i8 = 1;
        final int i9 = 0;
        if (bundle != null) {
            String string = bundle.getString("state_video_url");
            if (string == null) {
                string = "";
            }
            this.bs = string;
            String string2 = bundle.getString("state_title");
            this.bt = string2 != null ? string2 : "";
            this.bu = bundle.getString("state_logo_url");
            this.bw = Build.VERSION.SDK_INT >= 33 ? (ContentItem) bundle.getParcelable("state_content_item", ContentItem.class) : (ContentItem) bundle.getParcelable("state_content_item");
            this.bx = bundle.getInt("state_season", -1);
            this.bz = bundle.getInt("state_episode", -1);
            this.ca = bundle.getLong("state_position_ms", 0L);
            this.a0 = bundle.getLong("state_subtitle_delay", 0L);
            long j = bundle.getLong("audio_delay_ms", 0L);
            this.b0 = j;
            kx kxVar = this.c0;
            kxVar.a = j;
            kxVar.a();
            bundle.getBoolean("state_has_resumed", false);
            ExecutorService executorService = kq.a;
            kq.h("VideoPlayerActivity", "State restored: position=" + this.ca + ", title=" + this.bt);
        } else {
            String stringExtra = getIntent().getStringExtra("video_url");
            if (stringExtra == null) {
                stringExtra = "";
            }
            this.bs = stringExtra;
            String stringExtra2 = getIntent().getStringExtra("title");
            this.bt = stringExtra2 != null ? stringExtra2 : "";
            this.bu = getIntent().getStringExtra("logo_url");
            this.bw = Build.VERSION.SDK_INT >= 33 ? (ContentItem) getIntent().getParcelableExtra("content_item", ContentItem.class) : (ContentItem) getIntent().getParcelableExtra("content_item");
            this.bx = getIntent().getIntExtra("season", -1);
            this.bz = getIntent().getIntExtra(PlaybackProgress.TYPE_EPISODE, -1);
            this.ca = getIntent().getLongExtra("resume_position_ms", 0L);
            Serializable serializableExtra = getIntent().getSerializableExtra("proxy_headers");
            this.bv = serializableExtra instanceof Map ? (Map) serializableExtra : null;
            List list = ky8.a;
            this.ce = ky8.a;
            int i10 = ky8.b;
            this.cf = i10;
            StreamInfo streamInfo = (StreamInfo) y41.af(i10, this.ce);
            this.ci = streamInfo != null ? streamInfo.getBingeGroup() : null;
            boolean z = mr8.a;
            if (mr8.a) {
                int i11 = mr8.b;
                ContentItem contentItem = this.bw;
                boolean z2 = i11 == (contentItem != null ? contentItem.getTmdbId() : -1) && (aVarB = mr8.b()) != null && aVarB.a == this.bx && aVarB.b == this.bz;
                this.cc = z2;
                if (!z2 && mr8.a) {
                    mr8.a = false;
                    mr8.b = 0;
                    mr8.c = ik2.a;
                    mr8.d = 0;
                }
                this.cn = System.currentTimeMillis();
            }
        }
        this.w0 = new GestureDetector(this, new rha(this));
        this.r = (PlayerView) findViewById(R.id.player_view);
        this.s = (SubtitleView) findViewById(R.id.custom_subtitle_view);
        PlayerView playerView = this.r;
        if (playerView == null) {
            cr4.n("playerView");
            throw null;
        }
        SubtitleView subtitleView = playerView.getSubtitleView();
        if (subtitleView != null) {
            subtitleView.setVisibility(8);
        }
        this.t = (FrameLayout) findViewById(R.id.loading_overlay);
        this.u = (ImageView) findViewById(R.id.loading_backdrop);
        this.v = (ImageView) findViewById(R.id.loading_logo);
        this.w = (TextView) findViewById(R.id.loading_text);
        this.x = (ImageView) findViewById(R.id.loading_spinner);
        this.y = (FrameLayout) findViewById(R.id.error_overlay);
        this.z = (TextView) findViewById(R.id.error_message);
        this.aa = (TextView) findViewById(R.id.skip_indicator);
        this.ab = (ImageView) findViewById(R.id.buffering_indicator);
        this.Y = (FrameLayout) findViewById(R.id.adjustment_bar_container);
        Animation animationLoadAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate_spinner);
        ImageView imageView = this.x;
        if (imageView == null) {
            cr4.n("loadingSpinner");
            throw null;
        }
        imageView.startAnimation(animationLoadAnimation);
        View viewFindViewById = findViewById(R.id.player_controls);
        this.ac = viewFindViewById;
        if (viewFindViewById == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ad = (LinearLayout) viewFindViewById.findViewById(R.id.top_bar);
        View view = this.ac;
        if (view == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ae = (LinearLayout) view.findViewById(R.id.bottom_controls);
        View view2 = this.ac;
        if (view2 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.af = (TextView) view2.findViewById(R.id.video_title);
        View view3 = this.ac;
        if (view3 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ag = (TextView) view3.findViewById(R.id.episode_info);
        View view4 = this.ac;
        if (view4 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ah = (TextView) view4.findViewById(R.id.time_current);
        View view5 = this.ac;
        if (view5 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ai = (TextView) view5.findViewById(R.id.time_total);
        View view6 = this.ac;
        if (view6 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.aj = (TextView) view6.findViewById(R.id.end_time);
        View view7 = this.ac;
        if (view7 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ak = (SeekBar) view7.findViewById(R.id.seek_bar);
        View view8 = this.ac;
        if (view8 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.al = (ImageButton) view8.findViewById(R.id.btn_play_pause);
        View view9 = this.ac;
        if (view9 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.am = (ImageButton) view9.findViewById(R.id.btn_subtitles);
        View view10 = this.ac;
        if (view10 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.an = (ImageButton) view10.findViewById(R.id.btn_audio);
        View view11 = this.ac;
        if (view11 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ao = (ImageButton) view11.findViewById(R.id.btn_next_episode);
        View view12 = this.ac;
        if (view12 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ap = (ImageButton) view12.findViewById(R.id.btn_episodes_list);
        View view13 = this.ac;
        if (view13 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.aq = (ImageButton) view13.findViewById(R.id.btn_source);
        View view14 = this.ac;
        if (view14 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ar = (ImageButton) view14.findViewById(R.id.btn_speed);
        View view15 = this.ac;
        if (view15 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.as = (ImageButton) view15.findViewById(R.id.btn_aspect_ratio);
        View view16 = this.ac;
        if (view16 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.at = (ImageButton) view16.findViewById(R.id.btn_close_player);
        View view17 = this.ac;
        if (view17 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.au = (TextView) view17.findViewById(R.id.focused_button_label);
        View view18 = this.ac;
        if (view18 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.av = (LinearLayout) view18.findViewById(R.id.center_controls);
        View view19 = this.ac;
        if (view19 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.aw = (ImageButton) view19.findViewById(R.id.btn_center_play_pause);
        View view20 = this.ac;
        if (view20 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ax = (ImageButton) view20.findViewById(R.id.btn_center_rewind);
        View view21 = this.ac;
        if (view21 == null) {
            cr4.n("controlsRoot");
            throw null;
        }
        this.ay = (ImageButton) view21.findViewById(R.id.btn_center_forward);
        this.az = !getPackageManager().hasSystemFeature("android.software.leanback");
        this.ba = (FrameLayout) findViewById(R.id.pause_overlay);
        this.bb = (ImageView) findViewById(R.id.pause_logo);
        this.bc = (TextView) findViewById(R.id.pause_title);
        String logoUrl = this.bu;
        if (logoUrl == null) {
            ContentItem contentItem2 = this.bw;
            logoUrl = contentItem2 != null ? contentItem2.getLogoUrl() : null;
        }
        if (logoUrl == null || n89.ab(logoUrl)) {
            ImageView imageView2 = this.bb;
            if (imageView2 == null) {
                cr4.n("pauseLogo");
                throw null;
            }
            imageView2.setVisibility(8);
            TextView textView = this.bc;
            if (textView == null) {
                cr4.n("pauseTitle");
                throw null;
            }
            textView.setText(this.bt);
            TextView textView2 = this.bc;
            if (textView2 == null) {
                cr4.n("pauseTitle");
                throw null;
            }
            textView2.setVisibility(0);
        } else {
            l08 l08VarN = com.bumptech.glide.a.c(this).e(this).n(logoUrl);
            ImageView imageView3 = this.bb;
            if (imageView3 == null) {
                cr4.n("pauseLogo");
                throw null;
            }
            l08VarN.ah(imageView3);
            ImageView imageView4 = this.bb;
            if (imageView4 == null) {
                cr4.n("pauseLogo");
                throw null;
            }
            imageView4.setVisibility(0);
            TextView textView3 = this.bc;
            if (textView3 == null) {
                cr4.n("pauseTitle");
                throw null;
            }
            textView3.setVisibility(8);
        }
        this.F = (FrameLayout) findViewById(R.id.skip_intro_container);
        this.G = (Button) findViewById(R.id.btn_skip_intro);
        this.H = (ProgressBar) findViewById(R.id.skip_intro_progress);
        Button button = this.G;
        if (button == null) {
            cr4.n("btnSkipIntro");
            throw null;
        }
        final int i12 = 11;
        button.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view22) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str;
                ContentItem contentItem3;
                int i13;
                int i14 = 3;
                int i15 = 1;
                switch (i12) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView4 = dp2Var.f;
                                if (textView4 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView4.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i16 = 0;
                        while (true) {
                            if (i16 >= 6) {
                                i16 = -1;
                            } else if (fArr[i16] != videoPlayerActivity3.be) {
                                i16++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i16 >= 0 ? i16 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i15)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i14 = 0;
                        } else if (iOrdinal2 == 1) {
                            i14 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i14);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str = "Stretch";
                        }
                        videoPlayerActivity4.bj(str);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem3 = videoPlayerActivity9.bw) != null) {
                            contentItem3.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem3);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i17 = videoPlayerActivity9.bx;
                                if (i17 <= 0 || (i13 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i17, i13 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        this.bf = (CardView) findViewById(R.id.next_episode_overlay);
        this.bg = (ImageView) findViewById(R.id.next_episode_thumbnail);
        this.bh = (TextView) findViewById(R.id.next_episode_label);
        this.bi = (TextView) findViewById(R.id.next_episode_title);
        this.bj = (TextView) findViewById(R.id.next_episode_countdown);
        this.bk = (Button) findViewById(R.id.btn_play_next);
        this.bl = (Button) findViewById(R.id.btn_cancel_next);
        String str = (this.bx <= 0 || this.bz <= 0) ? this.bt : bm() + " S" + this.bx + "E" + this.bz;
        TextView textView4 = this.w;
        if (textView4 == null) {
            cr4.n("loadingText");
            throw null;
        }
        textView4.setText("Loading " + str + "...");
        ImageButton imageButton = this.at;
        if (imageButton == null) {
            cr4.n("btnClosePlayer");
            throw null;
        }
        imageButton.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view22) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem3;
                int i13;
                int i14 = 3;
                int i15 = 1;
                switch (i8) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i16 = 0;
                        while (true) {
                            if (i16 >= 6) {
                                i16 = -1;
                            } else if (fArr[i16] != videoPlayerActivity3.be) {
                                i16++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i16 >= 0 ? i16 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i15)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i14 = 0;
                        } else if (iOrdinal2 == 1) {
                            i14 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i14);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem3 = videoPlayerActivity9.bw) != null) {
                            contentItem3.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem3);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i17 = videoPlayerActivity9.bx;
                                if (i17 <= 0 || (i13 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i17, i13 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        if (this.bx <= 0 || this.bz <= 0) {
            TextView textView5 = this.af;
            if (textView5 == null) {
                cr4.n("videoTitle");
                throw null;
            }
            textView5.setText(this.bt);
        } else {
            TextView textView6 = this.af;
            if (textView6 == null) {
                cr4.n("videoTitle");
                throw null;
            }
            textView6.setText(bm());
        }
        ColorStateList colorStateList = sf1.getColorStateList(this, R.color.player_button_icon_tint);
        ImageButton imageButton2 = this.al;
        if (imageButton2 == null) {
            cr4.n("btnPlayPause");
            throw null;
        }
        ImageButton imageButton3 = this.ao;
        if (imageButton3 == null) {
            cr4.n("btnNextEpisode");
            throw null;
        }
        ImageButton imageButton4 = this.ap;
        if (imageButton4 == null) {
            cr4.n("btnEpisodesList");
            throw null;
        }
        ImageButton imageButton5 = this.am;
        if (imageButton5 == null) {
            cr4.n("btnSubtitles");
            throw null;
        }
        ImageButton imageButton6 = this.an;
        if (imageButton6 == null) {
            cr4.n("btnAudio");
            throw null;
        }
        ImageButton imageButton7 = this.aq;
        if (imageButton7 == null) {
            cr4.n("btnSource");
            throw null;
        }
        ImageButton imageButton8 = this.ar;
        if (imageButton8 == null) {
            cr4.n("btnSpeed");
            throw null;
        }
        ImageButton imageButton9 = this.as;
        if (imageButton9 == null) {
            cr4.n("btnAspectRatio");
            throw null;
        }
        Iterator it = y41.an(imageButton2, imageButton3, imageButton4, imageButton5, imageButton6, imageButton7, imageButton8, imageButton9).iterator();
        while (it.hasNext()) {
            ((ImageButton) it.next()).setImageTintList(colorStateList);
        }
        final int i13 = 9;
        if (getPackageManager().hasSystemFeature("android.software.leanback")) {
            ImageButton imageButton10 = this.al;
            if (imageButton10 == null) {
                cr4.n("btnPlayPause");
                throw null;
            }
            ImageButton imageButton11 = this.ao;
            if (imageButton11 == null) {
                cr4.n("btnNextEpisode");
                throw null;
            }
            i2 = 2;
            ImageButton imageButton12 = this.ap;
            if (imageButton12 == null) {
                cr4.n("btnEpisodesList");
                throw null;
            }
            ImageButton imageButton13 = this.am;
            if (imageButton13 == null) {
                cr4.n("btnSubtitles");
                throw null;
            }
            i3 = 7;
            ImageButton imageButton14 = this.an;
            if (imageButton14 == null) {
                cr4.n("btnAudio");
                throw null;
            }
            i4 = 6;
            ImageButton imageButton15 = this.aq;
            if (imageButton15 == null) {
                cr4.n("btnSource");
                throw null;
            }
            i5 = 5;
            ImageButton imageButton16 = this.ar;
            if (imageButton16 == null) {
                cr4.n("btnSpeed");
                throw null;
            }
            i6 = 4;
            ImageButton imageButton17 = this.as;
            if (imageButton17 == null) {
                cr4.n("btnAspectRatio");
                throw null;
            }
            i = 8;
            SeekBar seekBar = this.ak;
            if (seekBar == null) {
                cr4.n("seekBar");
                throw null;
            }
            i7 = 3;
            for (View view22 : y41.an(imageButton10, imageButton11, imageButton12, imageButton13, imageButton14, imageButton15, imageButton16, imageButton17, seekBar)) {
                view22.setFocusable(true);
                view22.setFocusableInTouchMode(true);
            }
            ImageButton imageButton18 = this.al;
            if (imageButton18 == null) {
                cr4.n("btnPlayPause");
                throw null;
            }
            q07 q07Var = new q07(imageButton18, "Play / Pause");
            ImageButton imageButton19 = this.ao;
            if (imageButton19 == null) {
                cr4.n("btnNextEpisode");
                throw null;
            }
            q07 q07Var2 = new q07(imageButton19, "Next Episode");
            ImageButton imageButton20 = this.ap;
            if (imageButton20 == null) {
                cr4.n("btnEpisodesList");
                throw null;
            }
            q07 q07Var3 = new q07(imageButton20, "Episodes");
            ImageButton imageButton21 = this.am;
            if (imageButton21 == null) {
                cr4.n("btnSubtitles");
                throw null;
            }
            q07 q07Var4 = new q07(imageButton21, "Subtitles");
            ImageButton imageButton22 = this.an;
            if (imageButton22 == null) {
                cr4.n("btnAudio");
                throw null;
            }
            q07 q07Var5 = new q07(imageButton22, "Audio Track");
            ImageButton imageButton23 = this.aq;
            if (imageButton23 == null) {
                cr4.n("btnSource");
                throw null;
            }
            q07 q07Var6 = new q07(imageButton23, "Source");
            ImageButton imageButton24 = this.ar;
            if (imageButton24 == null) {
                cr4.n("btnSpeed");
                throw null;
            }
            q07 q07Var7 = new q07(imageButton24, RtspHeaders.SPEED);
            ImageButton imageButton25 = this.as;
            if (imageButton25 == null) {
                cr4.n("btnAspectRatio");
                throw null;
            }
            for (Map.Entry entry : wo5.j(q07Var, q07Var2, q07Var3, q07Var4, q07Var5, q07Var6, q07Var7, new q07(imageButton25, "Aspect Ratio")).entrySet()) {
                ((ImageButton) entry.getKey()).setOnFocusChangeListener(new e62(this, (String) entry.getValue()));
            }
        } else {
            i = 8;
            i2 = 2;
            i3 = 7;
            i4 = 6;
            i5 = 5;
            i6 = 4;
            i7 = 3;
        }
        if (this.bx <= 0 || this.bz <= 0) {
            TextView textView7 = this.ag;
            if (textView7 == null) {
                cr4.n("episodeInfo");
                throw null;
            }
            textView7.setVisibility(i);
        } else {
            TextView textView8 = this.ag;
            if (textView8 == null) {
                cr4.n("episodeInfo");
                throw null;
            }
            textView8.setVisibility(0);
            if (this.cc) {
                boolean z3 = mr8.a;
                if (!mr8.a || (size = (mr8.c.size() - mr8.d) - 1) < 0) {
                    size = 0;
                }
                TextView textView9 = this.ag;
                if (textView9 == null) {
                    cr4.n("episodeInfo");
                    throw null;
                }
                StringBuilder sbR = vw2.r("S", this.bx, " E", " · Shuffle (", this.bz);
                sbR.append(size);
                sbR.append(" left)");
                textView9.setText(sbR.toString());
            } else {
                TextView textView10 = this.ag;
                if (textView10 == null) {
                    cr4.n("episodeInfo");
                    throw null;
                }
                textView10.setText("S" + this.bx + " E" + this.bz);
            }
            ContentItem contentItem3 = this.bw;
            if (contentItem3 != null) {
                wj0.c(androidx.lifecycle.s.a(this), null, null, new q(this, contentItem3.getTmdbId(), null), i7);
            }
        }
        ImageButton imageButton26 = this.al;
        if (imageButton26 == null) {
            cr4.n("btnPlayPause");
            throw null;
        }
        final int i14 = i6;
        imageButton26.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i15 = 1;
                switch (i14) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i16 = 0;
                        while (true) {
                            if (i16 >= 6) {
                                i16 = -1;
                            } else if (fArr[i16] != videoPlayerActivity3.be) {
                                i16++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i16 >= 0 ? i16 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i15)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i17 = videoPlayerActivity9.bx;
                                if (i17 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i17, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        ImageButton imageButton27 = this.aw;
        if (imageButton27 == null) {
            cr4.n("btnCenterPlayPause");
            throw null;
        }
        final int i15 = i5;
        imageButton27.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i15) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i16 = 0;
                        while (true) {
                            if (i16 >= 6) {
                                i16 = -1;
                            } else if (fArr[i16] != videoPlayerActivity3.be) {
                                i16++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i16 >= 0 ? i16 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i17 = videoPlayerActivity9.bx;
                                if (i17 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i17, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        ImageButton imageButton28 = this.ax;
        if (imageButton28 == null) {
            cr4.n("btnCenterRewind");
            throw null;
        }
        final int i16 = i4;
        imageButton28.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i16) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i17 = videoPlayerActivity9.bx;
                                if (i17 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i17, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        ImageButton imageButton29 = this.ay;
        if (imageButton29 == null) {
            cr4.n("btnCenterForward");
            throw null;
        }
        final int i17 = i3;
        imageButton29.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i17) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        if (this.az) {
            ImageButton imageButton30 = this.al;
            if (imageButton30 == null) {
                cr4.n("btnPlayPause");
                throw null;
            }
            imageButton30.setVisibility(8);
        }
        ImageButton imageButton31 = this.am;
        if (imageButton31 == null) {
            cr4.n("btnSubtitles");
            throw null;
        }
        imageButton31.setOnClickListener(new View.OnClickListener() { // from class: com.strmr.ps.ui.player.j
            @Override // android.view.View.OnClickListener
            public final void onClick(View view23) {
                String str2;
                VideoPlayerActivity videoPlayerActivity = this.a;
                if (videoPlayerActivity.bm != null) {
                    if (videoPlayerActivity.S.isEmpty() && !videoPlayerActivity.V) {
                        videoPlayerActivity.az();
                    }
                    h hVar = videoPlayerActivity.Q0;
                    if (hVar == null) {
                        h hVar2 = new h(videoPlayerActivity, videoPlayerActivity.S, videoPlayerActivity.T, videoPlayerActivity.V, videoPlayerActivity.a0, videoPlayerActivity.W, videoPlayerActivity.X, VideoPlayerActivity.br(videoPlayerActivity.bo.getSubtitleFont()), videoPlayerActivity.bo.getDefaultSubtitleLanguage(), new uga(videoPlayerActivity, 1, (byte) 0), new uga(videoPlayerActivity, 2, (byte) 0));
                        videoPlayerActivity.Q0 = hVar2;
                        hVar = hVar2;
                    }
                    if (!hVar.isShowing()) {
                        if (hVar.y) {
                            List list2 = videoPlayerActivity.S;
                            com.strmr.ps.data.subtitle.t tVar = videoPlayerActivity.T;
                            boolean z4 = videoPlayerActivity.V;
                            long j2 = videoPlayerActivity.a0;
                            int i18 = videoPlayerActivity.W;
                            int i19 = videoPlayerActivity.X;
                            String strBr = VideoPlayerActivity.br(videoPlayerActivity.bo.getSubtitleFont());
                            cr4.g(list2, "newSubtitles");
                            hVar.a = list2;
                            hVar.c = z4;
                            hVar.d = j2;
                            hVar.e = i18;
                            hVar.f = i19;
                            hVar.i = strBr;
                            hVar.ab.clear();
                            hVar.ac.clear();
                            if ((tVar instanceof t.c) || tVar == null) {
                                str2 = null;
                            } else if (tVar instanceof t.a) {
                                str2 = ((t.a) tVar).c;
                            } else {
                                if (!(tVar instanceof t.b)) {
                                    throw new io6();
                                }
                                str2 = ((t.b) tVar).a.c;
                            }
                            hVar.aa = str2;
                            hVar.a();
                            h.b bVar = hVar.ad;
                            if (bVar != null) {
                                bVar.b = hVar.aa;
                            }
                            if (bVar != null) {
                                bVar.notifyDataSetChanged();
                            }
                            h.e eVar = hVar.ae;
                            if (eVar != null) {
                                eVar.b = tVar;
                            }
                            if (eVar != null) {
                                eVar.notifyDataSetChanged();
                            }
                            hVar.d();
                            hVar.c();
                        }
                        hVar.show();
                    }
                }
                videoPlayerActivity.be();
            }
        });
        ImageButton imageButton32 = this.an;
        if (imageButton32 == null) {
            cr4.n("btnAudio");
            throw null;
        }
        final int i18 = 8;
        imageButton32.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i18) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        int i19 = this.bx;
        int i20 = this.bz;
        if (i19 <= 0 || i20 <= 0) {
            ImageButton imageButton33 = this.ao;
            if (imageButton33 == null) {
                cr4.n("btnNextEpisode");
                throw null;
            }
            imageButton33.setVisibility(8);
            ImageButton imageButton34 = this.ap;
            if (imageButton34 == null) {
                cr4.n("btnEpisodesList");
                throw null;
            }
            imageButton34.setVisibility(8);
            ImageButton imageButton35 = this.al;
            if (imageButton35 == null) {
                cr4.n("btnPlayPause");
                throw null;
            }
            imageButton35.setNextFocusRightId(R.id.btn_subtitles);
            ImageButton imageButton36 = this.am;
            if (imageButton36 == null) {
                cr4.n("btnSubtitles");
                throw null;
            }
            imageButton36.setNextFocusLeftId(R.id.btn_play_pause);
        } else {
            ImageButton imageButton37 = this.ao;
            if (imageButton37 == null) {
                cr4.n("btnNextEpisode");
                throw null;
            }
            imageButton37.setVisibility(0);
            ImageButton imageButton38 = this.ao;
            if (imageButton38 == null) {
                cr4.n("btnNextEpisode");
                throw null;
            }
            imageButton38.setOnClickListener(new View.OnClickListener(this) { // from class: tga
                public final /* synthetic */ VideoPlayerActivity b;

                {
                    this.b = this;
                }

                /* JADX WARN: Type inference fix 'apply assigned field type' failed
                java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
                	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
                	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
                	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
                 */
                @Override // android.view.View.OnClickListener
                public final void onClick(View view222) throws Throwable {
                    VideoPlayerActivity.a aVar;
                    String str2;
                    ContentItem contentItem32;
                    int i132;
                    int i142 = 3;
                    int i152 = 1;
                    switch (i13) {
                        case 0:
                            VideoPlayerActivity videoPlayerActivity = this.b;
                            ContentItem contentItem4 = videoPlayerActivity.bw;
                            if (contentItem4 != null) {
                                int tmdbId = contentItem4.getTmdbId();
                                if (videoPlayerActivity.bx <= 0) {
                                    Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                                } else {
                                    dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                    dp2Var.show();
                                    ProgressBar progressBar = dp2Var.e;
                                    if (progressBar == null) {
                                        cr4.n("loadingIndicator");
                                        throw null;
                                    }
                                    progressBar.setVisibility(0);
                                    RecyclerView recyclerView = dp2Var.d;
                                    if (recyclerView == null) {
                                        cr4.n("recyclerView");
                                        throw null;
                                    }
                                    recyclerView.setVisibility(8);
                                    TextView textView42 = dp2Var.f;
                                    if (textView42 == null) {
                                        cr4.n("emptyText");
                                        throw null;
                                    }
                                    textView42.setVisibility(8);
                                    wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                                }
                            }
                            videoPlayerActivity.be();
                            return;
                        case 1:
                            VideoPlayerActivity videoPlayerActivity2 = this.b;
                            long[] jArr = VideoPlayerActivity.R0;
                            videoPlayerActivity2.aj();
                            return;
                        case 2:
                            VideoPlayerActivity videoPlayerActivity3 = this.b;
                            float[] fArr = VideoPlayerActivity.S0;
                            int i162 = 0;
                            while (true) {
                                if (i162 >= 6) {
                                    i162 = -1;
                                } else if (fArr[i162] != videoPlayerActivity3.be) {
                                    i162++;
                                }
                            }
                            new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                            videoPlayerActivity3.be();
                            return;
                        case 3:
                            VideoPlayerActivity videoPlayerActivity4 = this.b;
                            int iOrdinal = videoPlayerActivity4.bd.ordinal();
                            if (iOrdinal == 0) {
                                aVar = VideoPlayerActivity.a.b;
                            } else if (iOrdinal == 1) {
                                aVar = VideoPlayerActivity.a.c;
                            } else {
                                if (iOrdinal != 2) {
                                    throw new io6();
                                }
                                aVar = VideoPlayerActivity.a.a;
                            }
                            videoPlayerActivity4.bd = aVar;
                            int iOrdinal2 = aVar.ordinal();
                            if (iOrdinal2 == 0) {
                                i142 = 0;
                            } else if (iOrdinal2 == 1) {
                                i142 = 4;
                            } else if (iOrdinal2 != 2) {
                                throw new io6();
                            }
                            PlayerView playerView2 = videoPlayerActivity4.r;
                            if (playerView2 == null) {
                                cr4.n("playerView");
                                throw null;
                            }
                            playerView2.setResizeMode(i142);
                            int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                            if (iOrdinal3 == 0) {
                                str2 = "Fit";
                            } else if (iOrdinal3 == 1) {
                                str2 = "Crop";
                            } else {
                                if (iOrdinal3 != 2) {
                                    throw new io6();
                                }
                                str2 = "Stretch";
                            }
                            videoPlayerActivity4.bj(str2);
                            videoPlayerActivity4.be();
                            return;
                        case 4:
                            VideoPlayerActivity videoPlayerActivity5 = this.b;
                            long[] jArr2 = VideoPlayerActivity.R0;
                            videoPlayerActivity5.bt();
                            videoPlayerActivity5.be();
                            return;
                        case 5:
                            VideoPlayerActivity videoPlayerActivity6 = this.b;
                            long[] jArr3 = VideoPlayerActivity.R0;
                            videoPlayerActivity6.bt();
                            videoPlayerActivity6.be();
                            return;
                        case 6:
                            VideoPlayerActivity videoPlayerActivity7 = this.b;
                            long[] jArr4 = VideoPlayerActivity.R0;
                            videoPlayerActivity7.bg();
                            videoPlayerActivity7.be();
                            return;
                        case 7:
                            VideoPlayerActivity videoPlayerActivity8 = this.b;
                            long[] jArr5 = VideoPlayerActivity.R0;
                            videoPlayerActivity8.bh();
                            videoPlayerActivity8.be();
                            return;
                        case 8:
                            VideoPlayerActivity.e(this.b);
                            return;
                        case 9:
                            VideoPlayerActivity videoPlayerActivity9 = this.b;
                            if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                                contentItem32.getTmdbId();
                                if (videoPlayerActivity9.cc) {
                                    videoPlayerActivity9.au();
                                    mr8.a aVarA = mr8.a();
                                    if (aVarA == null) {
                                        Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                        mr8.a = false;
                                        mr8.b = 0;
                                        mr8.c = ik2.a;
                                        mr8.d = 0;
                                    } else {
                                        videoPlayerActivity9.r0 = true;
                                        Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                        intent.putExtra("content_item", contentItem32);
                                        intent.putExtra("season", aVarA.a);
                                        intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                        intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                        intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                        videoPlayerActivity9.startActivity(intent);
                                        videoPlayerActivity9.finish();
                                    }
                                } else {
                                    int i172 = videoPlayerActivity9.bx;
                                    if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                        Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                    } else {
                                        videoPlayerActivity9.ba(i172, i132 + 1);
                                    }
                                }
                            }
                            videoPlayerActivity9.be();
                            return;
                        case 10:
                            VideoPlayerActivity videoPlayerActivity10 = this.b;
                            if (videoPlayerActivity10.ce.isEmpty()) {
                                Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                            } else {
                                new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                            }
                            videoPlayerActivity10.be();
                            return;
                        case 11:
                            VideoPlayerActivity videoPlayerActivity11 = this.b;
                            SkipInterval skipInterval = videoPlayerActivity11.J;
                            if (skipInterval == null) {
                                return;
                            }
                            ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                            if (exoPlayer != null) {
                                exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                            }
                            videoPlayerActivity11.av();
                            return;
                        case 12:
                            VideoPlayerActivity videoPlayerActivity12 = this.b;
                            long[] jArr6 = VideoPlayerActivity.R0;
                            videoPlayerActivity12.bb();
                            return;
                        default:
                            VideoPlayerActivity videoPlayerActivity13 = this.b;
                            long[] jArr7 = VideoPlayerActivity.R0;
                            videoPlayerActivity13.au();
                            return;
                    }
                }
            });
            ImageButton imageButton39 = this.ap;
            if (imageButton39 == null) {
                cr4.n("btnEpisodesList");
                throw null;
            }
            imageButton39.setVisibility(0);
            ImageButton imageButton40 = this.ap;
            if (imageButton40 == null) {
                cr4.n("btnEpisodesList");
                throw null;
            }
            imageButton40.setOnClickListener(new View.OnClickListener(this) { // from class: tga
                public final /* synthetic */ VideoPlayerActivity b;

                {
                    this.b = this;
                }

                /* JADX WARN: Type inference fix 'apply assigned field type' failed
                java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
                	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
                	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
                	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
                	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
                 */
                @Override // android.view.View.OnClickListener
                public final void onClick(View view222) throws Throwable {
                    VideoPlayerActivity.a aVar;
                    String str2;
                    ContentItem contentItem32;
                    int i132;
                    int i142 = 3;
                    int i152 = 1;
                    switch (i9) {
                        case 0:
                            VideoPlayerActivity videoPlayerActivity = this.b;
                            ContentItem contentItem4 = videoPlayerActivity.bw;
                            if (contentItem4 != null) {
                                int tmdbId = contentItem4.getTmdbId();
                                if (videoPlayerActivity.bx <= 0) {
                                    Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                                } else {
                                    dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                    dp2Var.show();
                                    ProgressBar progressBar = dp2Var.e;
                                    if (progressBar == null) {
                                        cr4.n("loadingIndicator");
                                        throw null;
                                    }
                                    progressBar.setVisibility(0);
                                    RecyclerView recyclerView = dp2Var.d;
                                    if (recyclerView == null) {
                                        cr4.n("recyclerView");
                                        throw null;
                                    }
                                    recyclerView.setVisibility(8);
                                    TextView textView42 = dp2Var.f;
                                    if (textView42 == null) {
                                        cr4.n("emptyText");
                                        throw null;
                                    }
                                    textView42.setVisibility(8);
                                    wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                                }
                            }
                            videoPlayerActivity.be();
                            return;
                        case 1:
                            VideoPlayerActivity videoPlayerActivity2 = this.b;
                            long[] jArr = VideoPlayerActivity.R0;
                            videoPlayerActivity2.aj();
                            return;
                        case 2:
                            VideoPlayerActivity videoPlayerActivity3 = this.b;
                            float[] fArr = VideoPlayerActivity.S0;
                            int i162 = 0;
                            while (true) {
                                if (i162 >= 6) {
                                    i162 = -1;
                                } else if (fArr[i162] != videoPlayerActivity3.be) {
                                    i162++;
                                }
                            }
                            new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                            videoPlayerActivity3.be();
                            return;
                        case 3:
                            VideoPlayerActivity videoPlayerActivity4 = this.b;
                            int iOrdinal = videoPlayerActivity4.bd.ordinal();
                            if (iOrdinal == 0) {
                                aVar = VideoPlayerActivity.a.b;
                            } else if (iOrdinal == 1) {
                                aVar = VideoPlayerActivity.a.c;
                            } else {
                                if (iOrdinal != 2) {
                                    throw new io6();
                                }
                                aVar = VideoPlayerActivity.a.a;
                            }
                            videoPlayerActivity4.bd = aVar;
                            int iOrdinal2 = aVar.ordinal();
                            if (iOrdinal2 == 0) {
                                i142 = 0;
                            } else if (iOrdinal2 == 1) {
                                i142 = 4;
                            } else if (iOrdinal2 != 2) {
                                throw new io6();
                            }
                            PlayerView playerView2 = videoPlayerActivity4.r;
                            if (playerView2 == null) {
                                cr4.n("playerView");
                                throw null;
                            }
                            playerView2.setResizeMode(i142);
                            int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                            if (iOrdinal3 == 0) {
                                str2 = "Fit";
                            } else if (iOrdinal3 == 1) {
                                str2 = "Crop";
                            } else {
                                if (iOrdinal3 != 2) {
                                    throw new io6();
                                }
                                str2 = "Stretch";
                            }
                            videoPlayerActivity4.bj(str2);
                            videoPlayerActivity4.be();
                            return;
                        case 4:
                            VideoPlayerActivity videoPlayerActivity5 = this.b;
                            long[] jArr2 = VideoPlayerActivity.R0;
                            videoPlayerActivity5.bt();
                            videoPlayerActivity5.be();
                            return;
                        case 5:
                            VideoPlayerActivity videoPlayerActivity6 = this.b;
                            long[] jArr3 = VideoPlayerActivity.R0;
                            videoPlayerActivity6.bt();
                            videoPlayerActivity6.be();
                            return;
                        case 6:
                            VideoPlayerActivity videoPlayerActivity7 = this.b;
                            long[] jArr4 = VideoPlayerActivity.R0;
                            videoPlayerActivity7.bg();
                            videoPlayerActivity7.be();
                            return;
                        case 7:
                            VideoPlayerActivity videoPlayerActivity8 = this.b;
                            long[] jArr5 = VideoPlayerActivity.R0;
                            videoPlayerActivity8.bh();
                            videoPlayerActivity8.be();
                            return;
                        case 8:
                            VideoPlayerActivity.e(this.b);
                            return;
                        case 9:
                            VideoPlayerActivity videoPlayerActivity9 = this.b;
                            if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                                contentItem32.getTmdbId();
                                if (videoPlayerActivity9.cc) {
                                    videoPlayerActivity9.au();
                                    mr8.a aVarA = mr8.a();
                                    if (aVarA == null) {
                                        Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                        mr8.a = false;
                                        mr8.b = 0;
                                        mr8.c = ik2.a;
                                        mr8.d = 0;
                                    } else {
                                        videoPlayerActivity9.r0 = true;
                                        Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                        intent.putExtra("content_item", contentItem32);
                                        intent.putExtra("season", aVarA.a);
                                        intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                        intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                        intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                        videoPlayerActivity9.startActivity(intent);
                                        videoPlayerActivity9.finish();
                                    }
                                } else {
                                    int i172 = videoPlayerActivity9.bx;
                                    if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                        Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                    } else {
                                        videoPlayerActivity9.ba(i172, i132 + 1);
                                    }
                                }
                            }
                            videoPlayerActivity9.be();
                            return;
                        case 10:
                            VideoPlayerActivity videoPlayerActivity10 = this.b;
                            if (videoPlayerActivity10.ce.isEmpty()) {
                                Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                            } else {
                                new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                            }
                            videoPlayerActivity10.be();
                            return;
                        case 11:
                            VideoPlayerActivity videoPlayerActivity11 = this.b;
                            SkipInterval skipInterval = videoPlayerActivity11.J;
                            if (skipInterval == null) {
                                return;
                            }
                            ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                            if (exoPlayer != null) {
                                exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                            }
                            videoPlayerActivity11.av();
                            return;
                        case 12:
                            VideoPlayerActivity videoPlayerActivity12 = this.b;
                            long[] jArr6 = VideoPlayerActivity.R0;
                            videoPlayerActivity12.bb();
                            return;
                        default:
                            VideoPlayerActivity videoPlayerActivity13 = this.b;
                            long[] jArr7 = VideoPlayerActivity.R0;
                            videoPlayerActivity13.au();
                            return;
                    }
                }
            });
            ImageButton imageButton41 = this.al;
            if (imageButton41 == null) {
                cr4.n("btnPlayPause");
                throw null;
            }
            imageButton41.setNextFocusRightId(R.id.btn_next_episode);
            ImageButton imageButton42 = this.am;
            if (imageButton42 == null) {
                cr4.n("btnSubtitles");
                throw null;
            }
            imageButton42.setNextFocusLeftId(R.id.btn_episodes_list);
        }
        ImageButton imageButton43 = this.aq;
        if (imageButton43 == null) {
            cr4.n("btnSource");
            throw null;
        }
        final int i21 = 10;
        imageButton43.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i21) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        ImageButton imageButton44 = this.ar;
        if (imageButton44 == null) {
            cr4.n("btnSpeed");
            throw null;
        }
        final int i22 = i2;
        imageButton44.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i22) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        ImageButton imageButton45 = this.as;
        if (imageButton45 == null) {
            cr4.n("btnAspectRatio");
            throw null;
        }
        final int i23 = 3;
        imageButton45.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i23) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        SeekBar seekBar2 = this.ak;
        if (seekBar2 == null) {
            cr4.n("seekBar");
            throw null;
        }
        seekBar2.setOnSeekBarChangeListener(new qha(this));
        SeekBar seekBar3 = this.ak;
        if (seekBar3 == null) {
            cr4.n("seekBar");
            throw null;
        }
        seekBar3.setOnKeyListener(new va(this, i23));
        LinearLayout linearLayout = this.ad;
        if (linearLayout == null) {
            cr4.n("topBar");
            throw null;
        }
        linearLayout.setVisibility(8);
        LinearLayout linearLayout2 = this.ae;
        if (linearLayout2 == null) {
            cr4.n("bottomControls");
            throw null;
        }
        linearLayout2.setVisibility(8);
        Button button2 = this.bk;
        if (button2 == null) {
            cr4.n("btnPlayNext");
            throw null;
        }
        final int i24 = 12;
        button2.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i24) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        Button button3 = this.bl;
        if (button3 == null) {
            cr4.n("btnCancelNext");
            throw null;
        }
        final int i25 = 13;
        button3.setOnClickListener(new View.OnClickListener(this) { // from class: tga
            public final /* synthetic */ VideoPlayerActivity b;

            {
                this.b = this;
            }

            /* JADX WARN: Type inference fix 'apply assigned field type' failed
            java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
            	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
            	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
            	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
            	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
             */
            @Override // android.view.View.OnClickListener
            public final void onClick(View view222) throws Throwable {
                VideoPlayerActivity.a aVar;
                String str2;
                ContentItem contentItem32;
                int i132;
                int i142 = 3;
                int i152 = 1;
                switch (i25) {
                    case 0:
                        VideoPlayerActivity videoPlayerActivity = this.b;
                        ContentItem contentItem4 = videoPlayerActivity.bw;
                        if (contentItem4 != null) {
                            int tmdbId = contentItem4.getTmdbId();
                            if (videoPlayerActivity.bx <= 0) {
                                Toast.makeText(videoPlayerActivity, "No season information available", 0).show();
                            } else {
                                dp2 dp2Var = new dp2(videoPlayerActivity, videoPlayerActivity.bx, videoPlayerActivity.bz, new uga(videoPlayerActivity, tmdbId));
                                dp2Var.show();
                                ProgressBar progressBar = dp2Var.e;
                                if (progressBar == null) {
                                    cr4.n("loadingIndicator");
                                    throw null;
                                }
                                progressBar.setVisibility(0);
                                RecyclerView recyclerView = dp2Var.d;
                                if (recyclerView == null) {
                                    cr4.n("recyclerView");
                                    throw null;
                                }
                                recyclerView.setVisibility(8);
                                TextView textView42 = dp2Var.f;
                                if (textView42 == null) {
                                    cr4.n("emptyText");
                                    throw null;
                                }
                                textView42.setVisibility(8);
                                wj0.c(s.a(videoPlayerActivity), null, null, new vha(dp2Var, videoPlayerActivity, tmdbId, null), 3);
                            }
                        }
                        videoPlayerActivity.be();
                        return;
                    case 1:
                        VideoPlayerActivity videoPlayerActivity2 = this.b;
                        long[] jArr = VideoPlayerActivity.R0;
                        videoPlayerActivity2.aj();
                        return;
                    case 2:
                        VideoPlayerActivity videoPlayerActivity3 = this.b;
                        float[] fArr = VideoPlayerActivity.S0;
                        int i162 = 0;
                        while (true) {
                            if (i162 >= 6) {
                                i162 = -1;
                            } else if (fArr[i162] != videoPlayerActivity3.be) {
                                i162++;
                            }
                        }
                        new gv3(videoPlayerActivity3, R.style.StrmrDialogTheme).setTitle((CharSequence) videoPlayerActivity3.getString(R.string.player_dialog_speed_title)).setSingleChoiceItems((CharSequence[]) VideoPlayerActivity.T0, i162 >= 0 ? i162 : 0, (DialogInterface.OnClickListener) new zga(videoPlayerActivity3, i152)).setCancelable(true).show();
                        videoPlayerActivity3.be();
                        return;
                    case 3:
                        VideoPlayerActivity videoPlayerActivity4 = this.b;
                        int iOrdinal = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal == 0) {
                            aVar = VideoPlayerActivity.a.b;
                        } else if (iOrdinal == 1) {
                            aVar = VideoPlayerActivity.a.c;
                        } else {
                            if (iOrdinal != 2) {
                                throw new io6();
                            }
                            aVar = VideoPlayerActivity.a.a;
                        }
                        videoPlayerActivity4.bd = aVar;
                        int iOrdinal2 = aVar.ordinal();
                        if (iOrdinal2 == 0) {
                            i142 = 0;
                        } else if (iOrdinal2 == 1) {
                            i142 = 4;
                        } else if (iOrdinal2 != 2) {
                            throw new io6();
                        }
                        PlayerView playerView2 = videoPlayerActivity4.r;
                        if (playerView2 == null) {
                            cr4.n("playerView");
                            throw null;
                        }
                        playerView2.setResizeMode(i142);
                        int iOrdinal3 = videoPlayerActivity4.bd.ordinal();
                        if (iOrdinal3 == 0) {
                            str2 = "Fit";
                        } else if (iOrdinal3 == 1) {
                            str2 = "Crop";
                        } else {
                            if (iOrdinal3 != 2) {
                                throw new io6();
                            }
                            str2 = "Stretch";
                        }
                        videoPlayerActivity4.bj(str2);
                        videoPlayerActivity4.be();
                        return;
                    case 4:
                        VideoPlayerActivity videoPlayerActivity5 = this.b;
                        long[] jArr2 = VideoPlayerActivity.R0;
                        videoPlayerActivity5.bt();
                        videoPlayerActivity5.be();
                        return;
                    case 5:
                        VideoPlayerActivity videoPlayerActivity6 = this.b;
                        long[] jArr3 = VideoPlayerActivity.R0;
                        videoPlayerActivity6.bt();
                        videoPlayerActivity6.be();
                        return;
                    case 6:
                        VideoPlayerActivity videoPlayerActivity7 = this.b;
                        long[] jArr4 = VideoPlayerActivity.R0;
                        videoPlayerActivity7.bg();
                        videoPlayerActivity7.be();
                        return;
                    case 7:
                        VideoPlayerActivity videoPlayerActivity8 = this.b;
                        long[] jArr5 = VideoPlayerActivity.R0;
                        videoPlayerActivity8.bh();
                        videoPlayerActivity8.be();
                        return;
                    case 8:
                        VideoPlayerActivity.e(this.b);
                        return;
                    case 9:
                        VideoPlayerActivity videoPlayerActivity9 = this.b;
                        if (!videoPlayerActivity9.r0 && (contentItem32 = videoPlayerActivity9.bw) != null) {
                            contentItem32.getTmdbId();
                            if (videoPlayerActivity9.cc) {
                                videoPlayerActivity9.au();
                                mr8.a aVarA = mr8.a();
                                if (aVarA == null) {
                                    Toast.makeText(videoPlayerActivity9, videoPlayerActivity9.getString(R.string.toast_all_shuffled_episodes_played), 0).show();
                                    mr8.a = false;
                                    mr8.b = 0;
                                    mr8.c = ik2.a;
                                    mr8.d = 0;
                                } else {
                                    videoPlayerActivity9.r0 = true;
                                    Intent intent = new Intent(videoPlayerActivity9, (Class<?>) SourcesActivity.class);
                                    intent.putExtra("content_item", contentItem32);
                                    intent.putExtra("season", aVarA.a);
                                    intent.putExtra(PlaybackProgress.TYPE_EPISODE, aVarA.b);
                                    intent.putExtra("preferred_binge_group", videoPlayerActivity9.ci);
                                    intent.addFlags(C.BUFFER_FLAG_NOT_DEPENDED_ON);
                                    videoPlayerActivity9.startActivity(intent);
                                    videoPlayerActivity9.finish();
                                }
                            } else {
                                int i172 = videoPlayerActivity9.bx;
                                if (i172 <= 0 || (i132 = videoPlayerActivity9.bz) <= 0) {
                                    Toast.makeText(videoPlayerActivity9, "No next episode available", 0).show();
                                } else {
                                    videoPlayerActivity9.ba(i172, i132 + 1);
                                }
                            }
                        }
                        videoPlayerActivity9.be();
                        return;
                    case 10:
                        VideoPlayerActivity videoPlayerActivity10 = this.b;
                        if (videoPlayerActivity10.ce.isEmpty()) {
                            Toast.makeText(videoPlayerActivity10, "No alternative sources available", 0).show();
                        } else {
                            new ay8(videoPlayerActivity10, videoPlayerActivity10.ce, videoPlayerActivity10.cf, new zd(videoPlayerActivity10, 22)).show();
                        }
                        videoPlayerActivity10.be();
                        return;
                    case 11:
                        VideoPlayerActivity videoPlayerActivity11 = this.b;
                        SkipInterval skipInterval = videoPlayerActivity11.J;
                        if (skipInterval == null) {
                            return;
                        }
                        ExoPlayer exoPlayer = videoPlayerActivity11.bm;
                        if (exoPlayer != null) {
                            exoPlayer.seekTo((long) (skipInterval.getEndTime() * ((double) 1000)));
                        }
                        videoPlayerActivity11.av();
                        return;
                    case 12:
                        VideoPlayerActivity videoPlayerActivity12 = this.b;
                        long[] jArr6 = VideoPlayerActivity.R0;
                        videoPlayerActivity12.bb();
                        return;
                    default:
                        VideoPlayerActivity videoPlayerActivity13 = this.b;
                        long[] jArr7 = VideoPlayerActivity.R0;
                        videoPlayerActivity13.au();
                        return;
                }
            }
        });
        FrameLayout frameLayout = this.t;
        if (frameLayout == null) {
            cr4.n("loadingOverlay");
            throw null;
        }
        frameLayout.setVisibility(0);
        FrameLayout frameLayout2 = this.y;
        if (frameLayout2 == null) {
            cr4.n("errorOverlay");
            throw null;
        }
        frameLayout2.setVisibility(8);
        ContentItem contentItem4 = this.bw;
        String backdropUrl = contentItem4 != null ? contentItem4.getBackdropUrl() : null;
        if (backdropUrl != null && !n89.ab(backdropUrl)) {
            if (Build.VERSION.SDK_INT >= 31) {
                Shader.TileMode tileMode = Shader.TileMode.CLAMP;
                RenderEffect renderEffectCreateBlurEffect = RenderEffect.createBlurEffect(20.0f, 20.0f, Shader.TileMode.CLAMP);
                cr4.f(renderEffectCreateBlurEffect, "createBlurEffect(...)");
                ImageView imageView5 = this.u;
                if (imageView5 == null) {
                    cr4.n("loadingBackdrop");
                    throw null;
                }
                imageView5.setRenderEffect(renderEffectCreateBlurEffect);
            }
            l08 l08VarN2 = com.bumptech.glide.a.c(this).e(this).n(backdropUrl);
            ImageView imageView6 = this.u;
            if (imageView6 == null) {
                cr4.n("loadingBackdrop");
                throw null;
            }
            l08VarN2.ah(imageView6);
        }
        String logoUrl2 = this.bu;
        if (logoUrl2 == null) {
            ContentItem contentItem5 = this.bw;
            logoUrl2 = contentItem5 != null ? contentItem5.getLogoUrl() : null;
        }
        if (logoUrl2 == null || n89.ab(logoUrl2)) {
            ImageView imageView7 = this.v;
            if (imageView7 == null) {
                cr4.n("loadingLogo");
                throw null;
            }
            imageView7.setVisibility(8);
        } else {
            l08 l08VarN3 = com.bumptech.glide.a.c(this).e(this).n(logoUrl2);
            ImageView imageView8 = this.v;
            if (imageView8 == null) {
                cr4.n("loadingLogo");
                throw null;
            }
            l08VarN3.ah(imageView8);
            if (!this.cs) {
                this.cs = true;
                ImageView imageView9 = this.v;
                if (imageView9 == null) {
                    cr4.n("loadingLogo");
                    throw null;
                }
                Property property = View.ALPHA;
                ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(imageView9, (Property<ImageView, Float>) property, 0.0f, 1.0f);
                objectAnimatorOfFloat.setDuration(1500L);
                ImageView imageView10 = this.v;
                if (imageView10 == null) {
                    cr4.n("loadingLogo");
                    throw null;
                }
                ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(imageView10, (Property<ImageView, Float>) property, 1.0f, 0.0f);
                objectAnimatorOfFloat2.setDuration(1500L);
                objectAnimatorOfFloat2.setStartDelay(ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS);
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playSequentially(objectAnimatorOfFloat, objectAnimatorOfFloat2);
                animatorSet.addListener(new cia(this, animatorSet));
                animatorSet.start();
                this.cr = animatorSet;
            }
        }
        int i26 = PlaybackService.b;
        String string3 = this.bt;
        if (n89.ab(string3)) {
            string3 = getString(R.string.app_name);
            cr4.f(string3, "getString(...)");
        }
        ContentItem contentItem6 = this.bw;
        ContentItem.ItemType itemType = contentItem6 != null ? contentItem6.getItemType() : null;
        int i27 = this.bx;
        int i28 = this.bz;
        Intent intent = new Intent(this, (Class<?>) PlaybackService.class);
        intent.putExtra("extra_title", string3);
        intent.putExtra("extra_content_type", itemType != null ? itemType.name() : null);
        intent.putExtra("extra_season", i27);
        intent.putExtra("extra_episode", i28);
        try {
            startForegroundService(intent);
        } catch (IllegalStateException e2) {
            n41.ab("Cannot start foreground service: ", e2.getMessage(), "PlaybackService");
        } catch (SecurityException e3) {
            n41.ab("PlaybackService start denied: ", e3.getMessage(), "PlaybackService");
        } catch (Exception e4) {
            n41.ab("Could not start PlaybackService: ", e4.getMessage(), "PlaybackService");
        }
        wj0.c(androidx.lifecycle.s.a(this), null, null, new w(this, null), 3);
    }

    @Override // defpackage.o74, androidx.fragment.app.t, android.app.Activity
    public final void onDestroy() {
        PlayerView playerView;
        c cVar;
        super.onDestroy();
        this.cs = false;
        AnimatorSet animatorSet = this.cr;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        this.cr = null;
        fx4 fx4Var = this.A;
        if (fx4Var != null) {
            ((rx4) fx4Var).h(null);
        }
        this.A = null;
        this.cz = false;
        if (this.cv) {
            pha phaVar = this.cw;
            if (phaVar != null) {
                Object systemService = getSystemService("display");
                DisplayManager displayManager = systemService instanceof DisplayManager ? (DisplayManager) systemService : null;
                if (displayManager != null) {
                    displayManager.unregisterDisplayListener(phaVar);
                }
                this.cw = null;
            }
            int i = this.cu;
            if (i >= 0) {
                try {
                    ExecutorService executorService = kq.a;
                    kq.h("FrameRate", "Restoring original display mode: " + i);
                    WindowManager.LayoutParams attributes = getWindow().getAttributes();
                    attributes.preferredDisplayModeId = this.cu;
                    getWindow().setAttributes(attributes);
                } catch (Exception e2) {
                    ExecutorService executorService2 = kq.a;
                    kq.a("FrameRate", "Failed to restore display mode", e2);
                }
            }
            this.cv = false;
        }
        int i2 = PlaybackService.b;
        stopService(new Intent(this, (Class<?>) PlaybackService.class));
        fx4 fx4Var2 = this.U;
        if (fx4Var2 != null) {
            ((rx4) fx4Var2).h(null);
        }
        if (this.P) {
            bq();
        }
        AudioFocusRequest audioFocusRequest = this.i0;
        if (audioFocusRequest != null) {
            AudioManager audioManager = this.h0;
            if (audioManager == null) {
                cr4.n("audioManager");
                throw null;
            }
            audioManager.abandonAudioFocusRequest(audioFocusRequest);
        }
        oha ohaVar = this.l0;
        if (ohaVar != null) {
            AudioManager audioManager2 = this.h0;
            if (audioManager2 == null) {
                cr4.n("audioManager");
                throw null;
            }
            audioManager2.unregisterAudioDeviceCallback(ohaVar);
        }
        this.l0 = null;
        if (this.u != null) {
            a18 a18VarF = com.bumptech.glide.a.f(getApplicationContext());
            ImageView imageView = this.u;
            if (imageView == null) {
                cr4.n("loadingBackdrop");
                throw null;
            }
            a18VarF.k(imageView);
        }
        if (this.v != null) {
            a18 a18VarF2 = com.bumptech.glide.a.f(getApplicationContext());
            ImageView imageView2 = this.v;
            if (imageView2 == null) {
                cr4.n("loadingLogo");
                throw null;
            }
            a18VarF2.k(imageView2);
        }
        if (this.bg != null) {
            a18 a18VarF3 = com.bumptech.glide.a.f(getApplicationContext());
            ImageView imageView3 = this.bg;
            if (imageView3 == null) {
                cr4.n("nextEpisodeThumbnail");
                throw null;
            }
            a18VarF3.k(imageView3);
        }
        fx4 fx4Var3 = this.ct;
        if (fx4Var3 != null) {
            ((rx4) fx4Var3).h(null);
        }
        bd();
        pha phaVar2 = this.cw;
        if (phaVar2 != null) {
            Object systemService2 = getSystemService("display");
            DisplayManager displayManager2 = systemService2 instanceof DisplayManager ? (DisplayManager) systemService2 : null;
            if (displayManager2 != null) {
                displayManager2.unregisterDisplayListener(phaVar2);
            }
            this.cw = null;
        }
        if (!n89.ab(this.bs)) {
            e17 e17Var = StrmrApp.w;
            e17 e17Var2 = StrmrApp.w;
            if (e17Var2 != null) {
                e17Var2.b(this.bs);
            }
        }
        MediaSession mediaSession = this.bn;
        if (mediaSession != null) {
            mediaSession.release();
        }
        this.bn = null;
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer != null && (cVar = this.g0) != null) {
            exoPlayer.removeListener(cVar);
        }
        c cVar2 = this.g0;
        if (cVar2 != null) {
            cVar2.a();
            cVar2.b.removeCallbacksAndMessages(null);
        }
        this.g0 = null;
        ExoPlayer exoPlayer2 = this.bm;
        if (exoPlayer2 != null) {
            try {
                playerView = this.r;
            } catch (Exception e3) {
                n41.ab("Error detaching surface: ", e3.getMessage(), "VideoPlayerActivity");
            }
            if (playerView == null) {
                cr4.n("playerView");
                throw null;
            }
            playerView.setPlayer(null);
            try {
                exoPlayer2.setPlayWhenReady(false);
                exoPlayer2.stop();
                exoPlayer2.clearMediaItems();
            } catch (Exception e4) {
                n41.ab("Error stopping player: ", e4.getMessage(), "VideoPlayerActivity");
            }
            try {
                exoPlayer2.release();
            } catch (Exception e5) {
                n41.ab("Error releasing player: ", e5.getMessage(), "VideoPlayerActivity");
            }
        }
        this.bm = null;
        this.bq = null;
        this.br = null;
        this.bp = null;
        this.u0 = false;
        this.v0 = false;
        this.cq.removeCallbacksAndMessages(null);
        List list = ky8.a;
        ky8.a = ik2.a;
        ky8.b = 0;
        ky8.c = -1;
        ky8.d = false;
        ContentItem contentItem = this.bw;
        int tmdbId = contentItem != null ? contentItem.getTmdbId() : -1;
        m12 m12Var = sc2.a;
        wj0.c(bk1.a(sm5.a.bz()), null, null, new x(this, tmdbId, null), 3);
    }

    /* JADX WARN: Code restructure failed: missing block: B:164:0x019a, code lost:
    
        if (r0.hasFocus() != false) goto L170;
     */
    @Override // android.app.Activity, android.view.KeyEvent.Callback
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onKeyDown(int i, KeyEvent keyEvent) throws Throwable {
        boolean z;
        com.strmr.ps.ui.player.a aVar = this.Z;
        if (aVar != null && (z = aVar.o)) {
            if (keyEvent != null && z) {
                int keyCode = keyEvent.getKeyCode();
                if (keyCode != 4) {
                    if (keyCode != 21) {
                        if (keyCode == 22 && keyEvent.getAction() == 0 && keyEvent.getRepeatCount() > 0) {
                            View view = aVar.f;
                            if (cr4.b(view != null ? view.findFocus() : null, aVar.j)) {
                                aVar.d();
                            }
                        }
                    } else if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() > 0) {
                        View view2 = aVar.f;
                        if (cr4.b(view2 != null ? view2.findFocus() : null, aVar.i)) {
                            aVar.a();
                        }
                    }
                } else if (keyEvent.getAction() == 0) {
                    aVar.c();
                    return true;
                }
            }
            return super.onKeyDown(i, keyEvent);
        }
        boolean z2 = this.q0;
        if (z2) {
            if (i == 4) {
                au();
                return true;
            }
            if (i != 62) {
                if (i != 66) {
                    if (i != 85) {
                        switch (i) {
                            case 19:
                                Button button = this.bk;
                                if (button == null) {
                                    cr4.n("btnPlayNext");
                                    throw null;
                                }
                                if (!button.hasFocus()) {
                                    Button button2 = this.bl;
                                    if (button2 == null) {
                                        cr4.n("btnCancelNext");
                                        throw null;
                                    }
                                    if (!button2.hasFocus()) {
                                        Button button3 = this.bk;
                                        if (button3 != null) {
                                            button3.requestFocus();
                                            return true;
                                        }
                                        cr4.n("btnPlayNext");
                                        throw null;
                                    }
                                }
                                break;
                            case 20:
                                Button button4 = this.bk;
                                if (button4 == null) {
                                    cr4.n("btnPlayNext");
                                    throw null;
                                }
                                if (!button4.hasFocus()) {
                                    Button button5 = this.bl;
                                    if (button5 == null) {
                                        cr4.n("btnCancelNext");
                                        throw null;
                                    }
                                    if (!button5.hasFocus()) {
                                        return super.onKeyDown(i, keyEvent);
                                    }
                                }
                                bk();
                                SeekBar seekBar = this.ak;
                                if (seekBar != null) {
                                    seekBar.requestFocus();
                                    return true;
                                }
                                cr4.n("seekBar");
                                throw null;
                            case 21:
                            case 22:
                                return super.onKeyDown(i, keyEvent);
                        }
                    }
                }
                return super.onKeyDown(i, keyEvent);
            }
            bt();
            return true;
        }
        if (i == 4) {
            if (this.M && !this.D) {
                av();
                return true;
            }
            if (this.D) {
                at();
                return true;
            }
            aj();
            return true;
        }
        if (i != 62) {
            if (i != 66) {
                if (i != 85) {
                    switch (i) {
                        case 19:
                            if (!this.D) {
                                bk();
                                return true;
                            }
                            if (!z2) {
                                be();
                                return super.onKeyDown(i, keyEvent);
                            }
                            Button button6 = this.bk;
                            if (button6 == null) {
                                cr4.n("btnPlayNext");
                                throw null;
                            }
                            button6.requestFocus();
                            be();
                            return true;
                        case 20:
                            if (this.D) {
                                be();
                                return super.onKeyDown(i, keyEvent);
                            }
                            bk();
                            return true;
                        case 21:
                            if (this.D) {
                                be();
                                return super.onKeyDown(i, keyEvent);
                            }
                            bg();
                            return true;
                        case 22:
                            if (this.D) {
                                be();
                                return super.onKeyDown(i, keyEvent);
                            }
                            bh();
                            return true;
                        case 23:
                            break;
                        default:
                            return super.onKeyDown(i, keyEvent);
                    }
                }
            }
            if (this.M) {
                Button button7 = this.G;
                if (button7 == null) {
                    cr4.n("btnSkipIntro");
                    throw null;
                }
                if (button7.hasFocus()) {
                    return super.onKeyDown(i, keyEvent);
                }
            }
            if (this.D) {
                SeekBar seekBar2 = this.ak;
                if (seekBar2 == null) {
                    cr4.n("seekBar");
                    throw null;
                }
                if (!seekBar2.hasFocus()) {
                    ImageButton imageButton = this.al;
                    if (imageButton == null) {
                        cr4.n("btnPlayPause");
                        throw null;
                    }
                    if (!imageButton.hasFocus()) {
                        ImageButton imageButton2 = this.am;
                        if (imageButton2 == null) {
                            cr4.n("btnSubtitles");
                            throw null;
                        }
                        if (!imageButton2.hasFocus()) {
                            ImageButton imageButton3 = this.an;
                            if (imageButton3 == null) {
                                cr4.n("btnAudio");
                                throw null;
                            }
                        }
                    }
                    be();
                    return super.onKeyDown(i, keyEvent);
                }
            }
            if (!this.D) {
                bk();
            }
            bt();
            be();
            return true;
        }
        bt();
        return true;
        return true;
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onPause() throws Throwable {
        super.onPause();
        this.co = System.currentTimeMillis();
        bf(true);
        wj0.c(androidx.lifecycle.s.a(this), null, null, new aj(this, null), 3);
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onResume() {
        super.onResume();
        aw();
    }

    @Override // defpackage.j91, defpackage.n91, android.app.Activity
    public final void onSaveInstanceState(Bundle bundle) {
        cr4.g(bundle, "outState");
        super.onSaveInstanceState(bundle);
        bundle.putString("state_video_url", this.bs);
        bundle.putString("state_title", this.bt);
        bundle.putString("state_logo_url", this.bu);
        bundle.putParcelable("state_content_item", this.bw);
        bundle.putInt("state_season", this.bx);
        bundle.putInt("state_episode", this.bz);
        ExoPlayer exoPlayer = this.bm;
        long currentPosition = exoPlayer != null ? exoPlayer.getCurrentPosition() : this.ca;
        bundle.putLong("state_position_ms", currentPosition);
        bundle.putLong("state_subtitle_delay", this.a0);
        bundle.putLong("audio_delay_ms", this.b0);
        bundle.putBoolean("state_has_resumed", true);
        ExecutorService executorService = kq.a;
        kq.h("VideoPlayerActivity", "State saved: position=" + currentPosition + ", title=" + this.bt);
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onStart() {
        super.onStart();
        long currentPosition = 0;
        if (this.co > 0 && this.cn > 0 && !this.cp) {
            long jCurrentTimeMillis = System.currentTimeMillis() - this.co;
            long jCurrentTimeMillis2 = System.currentTimeMillis() - this.cn;
            if (jCurrentTimeMillis > 1800000 && jCurrentTimeMillis2 > 1800000) {
                StreamInfo streamInfo = (StreamInfo) y41.af(this.cf, this.ce);
                if (streamInfo != null && !streamInfo.isDirectUrl()) {
                    this.cp = true;
                    try {
                        ExoPlayer exoPlayer = this.bm;
                        if (exoPlayer != null) {
                            currentPosition = exoPlayer.getCurrentPosition();
                        }
                    } catch (Exception unused) {
                    }
                    long j = currentPosition;
                    ExoPlayer exoPlayer2 = this.bm;
                    if (exoPlayer2 != null) {
                        exoPlayer2.setPlayWhenReady(false);
                    }
                    ExecutorService executorService = kq.a;
                    kq.h("VideoPlayer", "Re-resolving debrid link (age=" + ((System.currentTimeMillis() - this.cn) / ((long) 1000)) + "s)");
                    wj0.c(androidx.lifecycle.s.a(this), null, null, new ac(this, streamInfo, j, null), 3);
                    return;
                }
            }
        }
        ExoPlayer exoPlayer3 = this.bm;
        if (exoPlayer3 != null) {
            exoPlayer3.setPlayWhenReady(true);
        }
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onStop() {
        super.onStop();
        ExoPlayer exoPlayer = this.bm;
        if (exoPlayer != null) {
            exoPlayer.setPlayWhenReady(false);
        }
    }

    @Override // android.app.Activity
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        cr4.g(motionEvent, "event");
        GestureDetector gestureDetector = this.w0;
        if (gestureDetector == null) {
            cr4.n("gestureDetector");
            throw null;
        }
        if (gestureDetector.onTouchEvent(motionEvent)) {
            return true;
        }
        return super.onTouchEvent(motionEvent);
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x00f9  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void z(float f) {
        Display.Mode[] modeArr;
        Object next;
        if (this.cv) {
            return;
        }
        boolean zHasSystemFeature = getPackageManager().hasSystemFeature("android.software.leanback");
        ExecutorService executorService = kq.a;
        kq.h("FrameRate", "Frame rate matching: video=" + f + "fps, isTv=" + zHasSystemFeature);
        try {
            Display display = Build.VERSION.SDK_INT >= 30 ? getDisplay() : getWindowManager().getDefaultDisplay();
            if (display == null) {
                kq.h("FrameRate", "Display is null, cannot query display modes");
                this.cv = true;
                return;
            }
            Display.Mode mode = display.getMode();
            this.cu = mode.getModeId();
            kq.h("FrameRate", "Current display: mode=" + mode.getModeId() + " " + mode.getPhysicalWidth() + "x" + mode.getPhysicalHeight() + "@" + mode.getRefreshRate() + "Hz");
            Display.Mode[] supportedModes = display.getSupportedModes();
            int length = supportedModes.length;
            StringBuilder sb = new StringBuilder("Display.getSupportedModes() returned ");
            sb.append(length);
            sb.append(" mode(s)");
            kq.h("FrameRate", sb.toString());
            if (supportedModes.length <= 1) {
                Object systemService = getSystemService("display");
                DisplayManager displayManager = systemService instanceof DisplayManager ? (DisplayManager) systemService : null;
                Display[] displays = displayManager != null ? displayManager.getDisplays() : null;
                if (displays == null || displays.length == 0) {
                    modeArr = supportedModes;
                } else {
                    Display.Mode[] supportedModes2 = displays[0].getSupportedModes();
                    if (supportedModes2.length > supportedModes.length) {
                        kq.h("FrameRate", "DisplayManager returned " + supportedModes2.length + " mode(s) (more than Display API)");
                        modeArr = supportedModes2;
                    }
                }
            }
            kq.h("FrameRate", "Available modes: " + st.ag(modeArr, "; ", null, null, new cba(4), 30));
            ArrayList arrayList = new ArrayList();
            for (Display.Mode mode2 : modeArr) {
                if (mode2.getPhysicalWidth() == mode.getPhysicalWidth() && mode2.getPhysicalHeight() == mode.getPhysicalHeight()) {
                    arrayList.add(mode2);
                }
            }
            Iterator it = arrayList.iterator();
            if (it.hasNext()) {
                next = it.next();
                if (it.hasNext()) {
                    float refreshRate = ((Display.Mode) next).getRefreshRate();
                    float f2 = 2 * f;
                    float f3 = 2.5f * f;
                    float f4 = 3 * f;
                    Iterator it2 = y41.an(Float.valueOf(f), Float.valueOf(f2), Float.valueOf(f3), Float.valueOf(f4)).iterator();
                    if (!it2.hasNext()) {
                        throw new NoSuchElementException();
                    }
                    float fAbs = Math.abs(refreshRate - ((Number) it2.next()).floatValue());
                    while (it2.hasNext()) {
                        fAbs = Math.min(fAbs, Math.abs(refreshRate - ((Number) it2.next()).floatValue()));
                    }
                    while (true) {
                        Object next2 = it.next();
                        float refreshRate2 = ((Display.Mode) next2).getRefreshRate();
                        Iterator it3 = it;
                        Iterator it4 = y41.an(Float.valueOf(f), Float.valueOf(f2), Float.valueOf(f3), Float.valueOf(f4)).iterator();
                        if (!it4.hasNext()) {
                            throw new NoSuchElementException();
                        }
                        float fAbs2 = Math.abs(refreshRate2 - ((Number) it4.next()).floatValue());
                        while (it4.hasNext()) {
                            fAbs2 = Math.min(fAbs2, Math.abs(refreshRate2 - ((Number) it4.next()).floatValue()));
                        }
                        if (Float.compare(fAbs, fAbs2) > 0) {
                            next = next2;
                            fAbs = fAbs2;
                        }
                        if (!it3.hasNext()) {
                            break;
                        } else {
                            it = it3;
                        }
                    }
                }
            } else {
                next = null;
            }
            Display.Mode mode3 = (Display.Mode) next;
            if (mode3 == null || mode3.getModeId() == mode.getModeId()) {
                this.cz = false;
                ExecutorService executorService2 = kq.a;
                kq.h("FrameRate", "No better display mode found (" + mode.getRefreshRate() + "Hz is best for " + f + "fps)");
            } else {
                ExecutorService executorService3 = kq.a;
                kq.h("FrameRate", "Switching display mode: " + mode.getRefreshRate() + "Hz -> " + mode3.getRefreshRate() + "Hz (mode " + mode3.getModeId() + ") for " + f + "fps content");
                this.cz = true;
                int modeId = mode3.getModeId();
                float refreshRate3 = mode3.getRefreshRate();
                Object systemService2 = getSystemService("display");
                DisplayManager displayManager2 = systemService2 instanceof DisplayManager ? (DisplayManager) systemService2 : null;
                if (displayManager2 != null) {
                    pha phaVar = this.cw;
                    if (phaVar != null) {
                        displayManager2.unregisterDisplayListener(phaVar);
                    }
                    pha phaVar2 = new pha(refreshRate3, modeId, this);
                    this.cw = phaVar2;
                    displayManager2.registerDisplayListener(phaVar2, this.cq);
                }
                WindowManager.LayoutParams attributes = getWindow().getAttributes();
                attributes.preferredDisplayModeId = mode3.getModeId();
                getWindow().setAttributes(attributes);
                float refreshRate4 = mode3.getRefreshRate();
                fx4 fx4Var = this.A;
                if (fx4Var != null) {
                    ((rx4) fx4Var).h(null);
                }
                this.A = wj0.c(androidx.lifecycle.s.a(this), null, null, new an(this, refreshRate4, null), 3);
            }
            this.cv = true;
        } catch (Exception e2) {
            ExecutorService executorService4 = kq.a;
            kq.a("FrameRate", "Failed to apply frame rate matching", e2);
        }
    }
}
