package com.strmr.ps.ui.trailer;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.RenderEffect;
import android.graphics.Shader;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Property;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.t;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.upstream.CmcdData;
import com.strmr.ps.R;
import com.strmr.ps.ui.trailer.TrailerWebViewActivity;
import defpackage.cr4;
import defpackage.fr9;
import defpackage.hf5;
import defpackage.hr9;
import defpackage.ir9;
import defpackage.jr9;
import defpackage.l08;
import defpackage.n89;
import fi.iki.elonen.NanoHTTPD;
import java.util.Arrays;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\u00020\u0001:\u0002\u0004\u0005B\u0007¢\u0006\u0004\b\u0002\u0010\u0003¨\u0006\u0006"}, d2 = {"Lcom/strmr/ps/ui/trailer/TrailerWebViewActivity;", "Landroidx/fragment/app/t;", "<init>", "()V", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "b", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class TrailerWebViewActivity extends t {
    public WebView b;
    public ProgressBar c;
    public FrameLayout d;
    public ImageView e;
    public ImageView f;
    public View i;
    public WebChromeClient.CustomViewCallback j;
    public FrameLayout k;
    public FrameLayout l;
    public SeekBar m;
    public ImageView n;
    public TextView o;
    public TextView p;
    public AnimatorSet q;
    public boolean r;
    public boolean t;
    public final Handler s = new Handler(Looper.getMainLooper());
    public final fr9 u = new fr9(this, 0);
    public final c v = new c();

    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0010\t\n\u0002\b\u0006\b\u0086\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082T¢\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\n\u001a\u00020\t8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\n\u0010\u000bR\u0014\u0010\f\u001a\u00020\t8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\f\u0010\u000bR\u0014\u0010\r\u001a\u00020\t8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\r\u0010\u000bR\u0014\u0010\u000e\u001a\u00020\t8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u000e\u0010\u000b¨\u0006\u000f"}, d2 = {"Lcom/strmr/ps/ui/trailer/TrailerWebViewActivity$a;", "", "", "TAG", "Ljava/lang/String;", "EXTRA_VIDEO_KEY", "EXTRA_VIDEO_TITLE", "EXTRA_LOGO_URL", "EXTRA_BACKDROP_URL", "", "LOGO_FADE_DURATION", "J", "LOGO_DISPLAY_DURATION", "OSD_HIDE_DELAY", "OSD_POLL_INTERVAL", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
    }

    @Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0006\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0004\b\u0082\u0004\u0018\u00002\u00020\u0001J\u000f\u0010\u0003\u001a\u00020\u0002H\u0007¢\u0006\u0004\b\u0003\u0010\u0004J\u000f\u0010\u0005\u001a\u00020\u0002H\u0007¢\u0006\u0004\b\u0005\u0010\u0004J'\u0010\u000b\u001a\u00020\u00022\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\b\u001a\u00020\u00062\u0006\u0010\n\u001a\u00020\tH\u0007¢\u0006\u0004\b\u000b\u0010\f¨\u0006\r"}, d2 = {"Lcom/strmr/ps/ui/trailer/TrailerWebViewActivity$b;", "", "Le6a;", "onVideoPlaying", "()V", "onVideoError", "", "currentTime", "duration", "", "state", "onPlayerInfo", "(DDI)V", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public final class b {
        public b() {
        }

        @JavascriptInterface
        public final void onPlayerInfo(final double currentTime, final double duration, final int state) {
            final TrailerWebViewActivity trailerWebViewActivity = TrailerWebViewActivity.this;
            trailerWebViewActivity.runOnUiThread(new Runnable() { // from class: gr9
                @Override // java.lang.Runnable
                public final void run() {
                    TrailerWebViewActivity trailerWebViewActivity2 = trailerWebViewActivity;
                    TextView textView = trailerWebViewActivity2.o;
                    if (textView == null) {
                        cr4.n("osdTimeCurrent");
                        throw null;
                    }
                    double d = currentTime;
                    textView.setText(TrailerWebViewActivity.e(d));
                    TextView textView2 = trailerWebViewActivity2.p;
                    if (textView2 == null) {
                        cr4.n("osdTimeDuration");
                        throw null;
                    }
                    double d2 = duration;
                    textView2.setText(TrailerWebViewActivity.e(d2));
                    if (d2 > 0.0d) {
                        SeekBar seekBar = trailerWebViewActivity2.m;
                        if (seekBar == null) {
                            cr4.n("osdSeekBar");
                            throw null;
                        }
                        seekBar.setProgress((int) ((d / d2) * ((double) 1000)));
                    }
                    ImageView imageView = trailerWebViewActivity2.n;
                    if (imageView != null) {
                        imageView.setImageResource(state == 1 ? R.drawable.ic_pause : R.drawable.ic_play);
                    } else {
                        cr4.n("osdPlayPauseIcon");
                        throw null;
                    }
                }
            });
        }

        @JavascriptInterface
        public final void onVideoError() {
            TrailerWebViewActivity trailerWebViewActivity = TrailerWebViewActivity.this;
            trailerWebViewActivity.runOnUiThread(new fr9(trailerWebViewActivity, 4));
        }

        @JavascriptInterface
        public final void onVideoPlaying() {
            TrailerWebViewActivity trailerWebViewActivity = TrailerWebViewActivity.this;
            trailerWebViewActivity.runOnUiThread(new fr9(trailerWebViewActivity, 3));
        }
    }

    @Metadata(d1 = {"\u0000\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"com/strmr/ps/ui/trailer/TrailerWebViewActivity$c", "Ljava/lang/Runnable;", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class c implements Runnable {
        public c() {
        }

        @Override // java.lang.Runnable
        public final void run() {
            TrailerWebViewActivity trailerWebViewActivity = TrailerWebViewActivity.this;
            if (trailerWebViewActivity.t) {
                WebView webView = trailerWebViewActivity.b;
                if (webView == null) {
                    cr4.n("webView");
                    throw null;
                }
                webView.evaluateJavascript("getPlayerInfo()", null);
                trailerWebViewActivity.s.postDelayed(this, 500L);
            }
        }
    }

    public static final void d(TrailerWebViewActivity trailerWebViewActivity) {
        FrameLayout frameLayout = trailerWebViewActivity.d;
        if (frameLayout == null) {
            cr4.n("loadingOverlay");
            throw null;
        }
        if (frameLayout.getVisibility() != 0) {
            return;
        }
        trailerWebViewActivity.r = false;
        AnimatorSet animatorSet = trailerWebViewActivity.q;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        trailerWebViewActivity.q = null;
        FrameLayout frameLayout2 = trailerWebViewActivity.d;
        if (frameLayout2 != null) {
            frameLayout2.animate().alpha(0.0f).setDuration(400L).withEndAction(new fr9(trailerWebViewActivity, 2)).start();
        } else {
            cr4.n("loadingOverlay");
            throw null;
        }
    }

    public static String e(double d) {
        int i = (int) d;
        int i2 = i / 3600;
        int i3 = (i % 3600) / 60;
        int i4 = i % 60;
        return i2 > 0 ? String.format("%d:%02d:%02d", Arrays.copyOf(new Object[]{Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4)}, 3)) : String.format("%d:%02d", Arrays.copyOf(new Object[]{Integer.valueOf(i3), Integer.valueOf(i4)}, 2));
    }

    @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));
    }

    @Override // defpackage.n91, android.app.Activity, android.view.Window.Callback
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        cr4.g(keyEvent, "event");
        if (keyEvent.getAction() == 0) {
            int keyCode = keyEvent.getKeyCode();
            if (keyCode == 4) {
                if (this.i == null) {
                    finish();
                    return true;
                }
                WebView webView = this.b;
                if (webView == null) {
                    cr4.n("webView");
                    throw null;
                }
                WebChromeClient webChromeClient = webView.getWebChromeClient();
                if (webChromeClient != null) {
                    webChromeClient.onHideCustomView();
                }
                return true;
            }
            if (keyCode != 66) {
                if (keyCode == 85) {
                    WebView webView2 = this.b;
                    if (webView2 == null) {
                        cr4.n("webView");
                        throw null;
                    }
                    webView2.evaluateJavascript("if(player&&player.getPlayerState()===1)player.pauseVideo();else if(player)player.playVideo();", null);
                    f();
                    return true;
                }
                if (keyCode != 89) {
                    if (keyCode != 90) {
                        if (keyCode == 126) {
                            WebView webView3 = this.b;
                            if (webView3 == null) {
                                cr4.n("webView");
                                throw null;
                            }
                            webView3.evaluateJavascript("if(player)player.playVideo();", null);
                            f();
                            return true;
                        }
                        if (keyCode == 127) {
                            WebView webView4 = this.b;
                            if (webView4 == null) {
                                cr4.n("webView");
                                throw null;
                            }
                            webView4.evaluateJavascript("if(player)player.pauseVideo();", null);
                            f();
                            return true;
                        }
                        if (keyCode != 272) {
                            if (keyCode != 273) {
                                switch (keyCode) {
                                    case 19:
                                    case 20:
                                        f();
                                        return true;
                                    case 21:
                                        WebView webView5 = this.b;
                                        if (webView5 == null) {
                                            cr4.n("webView");
                                            throw null;
                                        }
                                        webView5.evaluateJavascript("if(player)player.seekTo(Math.max(0,player.getCurrentTime()-10),true);", null);
                                        f();
                                        return true;
                                    case 22:
                                        WebView webView6 = this.b;
                                        if (webView6 == null) {
                                            cr4.n("webView");
                                            throw null;
                                        }
                                        webView6.evaluateJavascript("if(player)player.seekTo(player.getCurrentTime()+10,true);", null);
                                        f();
                                        return true;
                                }
                            }
                        }
                    }
                    WebView webView7 = this.b;
                    if (webView7 == null) {
                        cr4.n("webView");
                        throw null;
                    }
                    webView7.evaluateJavascript("if(player)player.seekTo(player.getCurrentTime()+30,true);", null);
                    f();
                    return true;
                }
                WebView webView8 = this.b;
                if (webView8 == null) {
                    cr4.n("webView");
                    throw null;
                }
                webView8.evaluateJavascript("if(player)player.seekTo(Math.max(0,player.getCurrentTime()-30),true);", null);
                f();
                return true;
            }
            WebView webView9 = this.b;
            if (webView9 == null) {
                cr4.n("webView");
                throw null;
            }
            webView9.evaluateJavascript("if(player&&player.getPlayerState()===1)player.pauseVideo();else if(player)player.playVideo();", null);
            f();
            return true;
        }
        return super.dispatchKeyEvent(keyEvent);
    }

    public final void f() {
        FrameLayout frameLayout = this.d;
        if (frameLayout == null) {
            cr4.n("loadingOverlay");
            throw null;
        }
        if (frameLayout.getVisibility() == 0) {
            return;
        }
        boolean z = this.t;
        Handler handler = this.s;
        if (!z) {
            this.t = true;
            FrameLayout frameLayout2 = this.l;
            if (frameLayout2 == null) {
                cr4.n("osdOverlay");
                throw null;
            }
            frameLayout2.setVisibility(0);
            FrameLayout frameLayout3 = this.l;
            if (frameLayout3 == null) {
                cr4.n("osdOverlay");
                throw null;
            }
            frameLayout3.setAlpha(0.0f);
            FrameLayout frameLayout4 = this.l;
            if (frameLayout4 == null) {
                cr4.n("osdOverlay");
                throw null;
            }
            frameLayout4.animate().alpha(1.0f).setDuration(200L).start();
            handler.post(this.v);
        }
        fr9 fr9Var = this.u;
        handler.removeCallbacks(fr9Var);
        handler.postDelayed(fr9Var, 4000L);
    }

    @Override // androidx.fragment.app.t, defpackage.j91, defpackage.n91, android.app.Activity
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_trailer_webview);
        this.b = (WebView) findViewById(R.id.trailer_webview);
        this.c = (ProgressBar) findViewById(R.id.loading_progress);
        this.k = (FrameLayout) findViewById(R.id.fullscreen_container);
        this.d = (FrameLayout) findViewById(R.id.loading_overlay);
        this.e = (ImageView) findViewById(R.id.loading_backdrop);
        this.f = (ImageView) findViewById(R.id.loading_logo);
        this.l = (FrameLayout) findViewById(R.id.osd_overlay);
        this.m = (SeekBar) findViewById(R.id.osd_seekbar);
        this.n = (ImageView) findViewById(R.id.osd_play_pause_icon);
        this.o = (TextView) findViewById(R.id.osd_time_current);
        this.p = (TextView) findViewById(R.id.osd_time_duration);
        String stringExtra = getIntent().getStringExtra("video_key");
        if (stringExtra == null || n89.ab(stringExtra)) {
            Toast.makeText(this, "No video key provided", 0).show();
            finish();
            return;
        }
        FrameLayout frameLayout = this.d;
        if (frameLayout == null) {
            cr4.n("loadingOverlay");
            throw null;
        }
        frameLayout.setVisibility(0);
        String stringExtra2 = getIntent().getStringExtra("backdrop_url");
        if (stringExtra2 != null && !n89.ab(stringExtra2)) {
            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 imageView = this.e;
                if (imageView == null) {
                    cr4.n("loadingBackdrop");
                    throw null;
                }
                imageView.setRenderEffect(renderEffectCreateBlurEffect);
            }
            l08 l08VarN = com.bumptech.glide.a.c(this).e(this).n(stringExtra2);
            ImageView imageView2 = this.e;
            if (imageView2 == null) {
                cr4.n("loadingBackdrop");
                throw null;
            }
            l08VarN.ah(imageView2);
        }
        String stringExtra3 = getIntent().getStringExtra("logo_url");
        if (stringExtra3 == null || n89.ab(stringExtra3)) {
            ImageView imageView3 = this.f;
            if (imageView3 == null) {
                cr4.n("loadingLogo");
                throw null;
            }
            imageView3.setVisibility(8);
        } else {
            l08 l08VarN2 = com.bumptech.glide.a.c(this).e(this).n(stringExtra3);
            ImageView imageView4 = this.f;
            if (imageView4 == null) {
                cr4.n("loadingLogo");
                throw null;
            }
            l08VarN2.ah(imageView4);
            if (!this.r) {
                this.r = true;
                ImageView imageView5 = this.f;
                if (imageView5 == null) {
                    cr4.n("loadingLogo");
                    throw null;
                }
                Property property = View.ALPHA;
                ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(imageView5, (Property<ImageView, Float>) property, 0.0f, 1.0f);
                objectAnimatorOfFloat.setDuration(1500L);
                ImageView imageView6 = this.f;
                if (imageView6 == null) {
                    cr4.n("loadingLogo");
                    throw null;
                }
                ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(imageView6, (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 jr9(this, animatorSet));
                animatorSet.start();
                this.q = animatorSet;
            }
        }
        WebView webView = this.b;
        if (webView == null) {
            cr4.n("webView");
            throw null;
        }
        webView.setBackgroundColor(0);
        WebView webView2 = this.b;
        if (webView2 == null) {
            cr4.n("webView");
            throw null;
        }
        WebSettings settings = webView2.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setMediaPlaybackRequiresUserGesture(false);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        settings.setCacheMode(-1);
        settings.setAllowContentAccess(true);
        settings.setSupportMultipleWindows(false);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setMixedContentMode(0);
        settings.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
        WebView webView3 = this.b;
        if (webView3 == null) {
            cr4.n("webView");
            throw null;
        }
        webView3.addJavascriptInterface(new b(), "AndroidBridge");
        WebView webView4 = this.b;
        if (webView4 == null) {
            cr4.n("webView");
            throw null;
        }
        webView4.setWebViewClient(new hr9(this));
        WebView webView5 = this.b;
        if (webView5 == null) {
            cr4.n("webView");
            throw null;
        }
        webView5.setWebChromeClient(new ir9(this));
        String strBi = n89.bi("\n            <!DOCTYPE html>\n            <html>\n            <head>\n                <meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1\">\n                <style>\n                    * { margin: 0; padding: 0; }\n                    html, body { width: 100%; height: 100%; background: #000; overflow: hidden; }\n                    #player { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }\n                    #error { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);\n                             color: #aaa; font-family: sans-serif; font-size: 18px; text-align: center; }\n                </style>\n            </head>\n            <body>\n                <div id=\"player\"></div>\n                <div id=\"error\"></div>\n                <script>\n                    var tag = document.createElement('script');\n                    tag.src = 'https://www.youtube.com/iframe_api';\n                    document.body.appendChild(tag);\n\n                    var player;\n                    var hasNotifiedPlaying = false;\n\n                    function notifyPlaying() {\n                        if (!hasNotifiedPlaying) {\n                            hasNotifiedPlaying = true;\n                            try { AndroidBridge.onVideoPlaying(); } catch(e) {}\n                        }\n                    }\n\n                    function getPlayerInfo() {\n                        if (player && player.getCurrentTime && player.getDuration) {\n                            try {\n                                AndroidBridge.onPlayerInfo(\n                                    player.getCurrentTime(),\n                                    player.getDuration(),\n                                    player.getPlayerState()\n                                );\n                            } catch(e) {}\n                        }\n                    }\n\n                    function pickBestQuality(p) {\n                        try {\n                            var levels = p.getAvailableQualityLevels ? p.getAvailableQualityLevels() : [];\n                            var preferred = ['highres','hd2160','hd1440','hd1080','hd720'];\n                            for (var i = 0; i < preferred.length; i++) {\n                                if (levels.indexOf(preferred[i]) !== -1) return preferred[i];\n                            }\n                        } catch(e) {}\n                        return 'hd1080';\n                    }\n\n                    function createPlayer(videoId, host) {\n                        return new YT.Player('player', {\n                            videoId: videoId,\n                            host: host,\n                            playerVars: {\n                                autoplay: 1,\n                                controls: 0,\n                                rel: 0,\n                                modestbranding: 1,\n                                playsinline: 0,\n                                fs: 0,\n                                iv_load_policy: 3,\n                                disablekb: 1,\n                                showinfo: 0,\n                                vq: 'hd1080',\n                                hd: 1\n                            },\n                            events: {\n                                onReady: function(e) {\n                                    try { e.target.setPlaybackQuality(pickBestQuality(e.target)); } catch(ex) {}\n                                },\n                                onPlaybackQualityChange: function(e) {\n                                    try {\n                                        var best = pickBestQuality(e.target);\n                                        if (e.data !== best && e.data !== 'hd1080' && e.data !== 'hd720' && e.data !== 'highres') {\n                                            e.target.setPlaybackQuality(best);\n                                        }\n                                    } catch(ex) {}\n                                },\n                                onStateChange: function(e) {\n                                    // YT.PlayerState.PLAYING = 1, BUFFERING = 3\n                                    if (e.data === 1) {\n                                        notifyPlaying();\n                                        try { player.setPlaybackQuality(pickBestQuality(player)); } catch(ex) {}\n                                    }\n                                    // Notify state change for OSD updates\n                                    try {\n                                        AndroidBridge.onPlayerInfo(\n                                            player.getCurrentTime(),\n                                            player.getDuration(),\n                                            e.data\n                                        );\n                                    } catch(ex) {}\n                                },\n                                onError: function(e) {\n                                    if (host === 'https://www.youtube-nocookie.com' && (e.data === 150 || e.data === 153)) {\n                                        document.getElementById('player').innerHTML = '';\n                                        player = createPlayer('" + stringExtra + "', 'https://www.youtube.com');\n                                    } else {\n                                        document.getElementById('error').style.display = 'block';\n                                        document.getElementById('error').innerText = e.data === 150 || e.data === 153\n                                            ? 'This trailer cannot be played in-app. Try YouTube App in Settings > Playback.'\n                                            : 'Playback error ' + e.data;\n                                        try { AndroidBridge.onVideoError(); } catch(ex) {}\n                                    }\n                                }\n                            }\n                        });\n                    }\n\n                    function onYouTubeIframeAPIReady() {\n                        player = createPlayer('" + stringExtra + "', 'https://www.youtube-nocookie.com');\n                    }\n                </script>\n            </body>\n            </html>\n        ");
        WebView webView6 = this.b;
        if (webView6 != null) {
            webView6.loadDataWithBaseURL("https://www.youtube-nocookie.com", strBi, NanoHTTPD.MIME_HTML, "UTF-8", null);
        } else {
            cr4.n("webView");
            throw null;
        }
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onDestroy() {
        this.s.removeCallbacksAndMessages(null);
        this.r = false;
        AnimatorSet animatorSet = this.q;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        this.q = null;
        WebView webView = this.b;
        if (webView == null) {
            cr4.n("webView");
            throw null;
        }
        webView.removeJavascriptInterface("AndroidBridge");
        WebView webView2 = this.b;
        if (webView2 == null) {
            cr4.n("webView");
            throw null;
        }
        webView2.stopLoading();
        WebView webView3 = this.b;
        if (webView3 == null) {
            cr4.n("webView");
            throw null;
        }
        webView3.destroy();
        super.onDestroy();
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onPause() {
        super.onPause();
        WebView webView = this.b;
        if (webView != null) {
            webView.onPause();
        } else {
            cr4.n("webView");
            throw null;
        }
    }

    @Override // androidx.fragment.app.t, android.app.Activity
    public final void onResume() {
        super.onResume();
        WebView webView = this.b;
        if (webView != null) {
            webView.onResume();
        } else {
            cr4.n("webView");
            throw null;
        }
    }
}
