互联科技 v1.0.0版本的 MD5 值为:8b52313fe679d352bd7a0e5122485fc1

以下内容为反编译后的 WebPlayerView.java 源代码,内容仅作参考


package im.pnsozvszmx.ui.components;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Base64;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.core.internal.view.SupportMenu;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.gms.common.internal.ImagesContract;
import com.google.android.gms.wearable.WearableStatusCodes;
import com.king.zxing.util.LogUtils;
import csgtwq.eijwdl.rarhdv.R;
import im.pnsozvszmx.messenger.AndroidUtilities;
import im.pnsozvszmx.messenger.ApplicationLoader;
import im.pnsozvszmx.messenger.Bitmaps;
import im.pnsozvszmx.messenger.BuildVars;
import im.pnsozvszmx.messenger.FileLoader;
import im.pnsozvszmx.messenger.FileLog;
import im.pnsozvszmx.messenger.ImageLocation;
import im.pnsozvszmx.messenger.ImageReceiver;
import im.pnsozvszmx.messenger.Utilities;
import im.pnsozvszmx.tgnet.TLRPC;
import im.pnsozvszmx.ui.components.VideoPlayer;
import im.pnsozvszmx.ui.components.WebPlayerView;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Marker;

public class WebPlayerView extends ViewGroup implements VideoPlayer.VideoPlayerDelegate, AudioManager.OnAudioFocusChangeListener {
    private static final int AUDIO_FOCUSED = 2;
    private static final int AUDIO_NO_FOCUS_CAN_DUCK = 1;
    private static final int AUDIO_NO_FOCUS_NO_DUCK = 0;
    private static final String exprName = "[a-zA-Z_$][a-zA-Z_$0-9]*";
    private boolean allowInlineAnimation;
    private AspectRatioFrameLayout aspectRatioFrameLayout;
    private int audioFocus;
    private Paint backgroundPaint;
    private TextureView changedTextureView;
    private boolean changingTextureView;
    private ControlsView controlsView;
    private float currentAlpha;
    private Bitmap currentBitmap;
    private AsyncTask currentTask;
    private String currentYoutubeId;
    private WebPlayerViewDelegate delegate;
    private boolean drawImage;
    private boolean firstFrameRendered;
    private int fragment_container_id;
    private ImageView fullscreenButton;
    private boolean hasAudioFocus;
    private boolean inFullscreen;
    private boolean initFailed;
    private boolean initied;
    private ImageView inlineButton;
    private String interfaceName;
    private boolean isAutoplay;
    private boolean isCompleted;
    private boolean isInline;
    private boolean isLoading;
    private boolean isStream;
    private long lastUpdateTime;
    private String playAudioType;
    private String playAudioUrl;
    private ImageView playButton;
    private String playVideoType;
    private String playVideoUrl;
    private AnimatorSet progressAnimation;
    private Runnable progressRunnable;
    private RadialProgressView progressView;
    private boolean resumeAudioOnFocusGain;
    private int seekToTime;
    private ImageView shareButton;
    private TextureView.SurfaceTextureListener surfaceTextureListener;
    private Runnable switchToInlineRunnable;
    private boolean switchingInlineMode;
    private ImageView textureImageView;
    private TextureView textureView;
    private ViewGroup textureViewContainer;
    private VideoPlayer videoPlayer;
    private int waitingForFirstTextureUpload;
    private WebView webView;
    private static int lastContainerId = WearableStatusCodes.DUPLICATE_LISTENER;
    private static final Pattern youtubeIdRegex = Pattern.compile("(?:youtube(?:-nocookie)?\\.com/(?:[^/\\n\\s]+/\\S+/|(?:v|e(?:mbed)?)/|\\S*?[?&]v=)|youtu\\.be/)([a-zA-Z0-9_-]{11})");
    private static final Pattern vimeoIdRegex = Pattern.compile("https?://(?:(?:www|(player))\\.)?vimeo(pro)?\\.com/(?!(?:channels|album)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)(?:.*?/)?(?:(?:play_redirect_hls|moogaloop\\.swf)\\?clip_id=)?(?:videos?/)?([0-9]+)(?:/[\\da-f]+)?/?(?:[?&].*)?(?:[#].*)?$");
    private static final Pattern coubIdRegex = Pattern.compile("(?:coub:|https?://(?:coub\\.com/(?:view|embed|coubs)/|c-cdn\\.coub\\.com/fb-player\\.swf\\?.*\\bcoub(?:ID|id)=))([\\da-z]+)");
    private static final Pattern aparatIdRegex = Pattern.compile("^https?://(?:www\\.)?aparat\\.com/(?:v/|video/video/embed/videohash/)([a-zA-Z0-9]+)");
    private static final Pattern twitchClipIdRegex = Pattern.compile("https?://clips\\.twitch\\.tv/(?:[^/]+/)*([^/?#&]+)");
    private static final Pattern twitchStreamIdRegex = Pattern.compile("https?://(?:(?:www\\.)?twitch\\.tv/|player\\.twitch\\.tv/\\?.*?\\bchannel=)([^/#?]+)");
    private static final Pattern aparatFileListPattern = Pattern.compile("fileList\\s*=\\s*JSON\\.parse\\('([^']+)'\\)");
    private static final Pattern twitchClipFilePattern = Pattern.compile("clipInfo\\s*=\\s*(\\{[^']+\\});");
    private static final Pattern stsPattern = Pattern.compile("\"sts\"\\s*:\\s*(\\d+)");
    private static final Pattern jsPattern = Pattern.compile("\"assets\":.+?\"js\":\\s*(\"[^\"]+\")");
    private static final Pattern sigPattern = Pattern.compile("\\.sig\\|\\|([a-zA-Z0-9$]+)\\(");
    private static final Pattern sigPattern2 = Pattern.compile("[\"']signature[\"']\\s*,\\s*([a-zA-Z0-9$]+)\\(");
    private static final Pattern stmtVarPattern = Pattern.compile("var\\s");
    private static final Pattern stmtReturnPattern = Pattern.compile("return(?:\\s+|$)");
    private static final Pattern exprParensPattern = Pattern.compile("[()]");
    private static final Pattern playerIdPattern = Pattern.compile(".*?-([a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2}_[A-Z]{2})?/base)?\\.([a-z]+)$");

    public interface CallJavaResultInterface {
        void jsCallFinished(String str);
    }

    public interface WebPlayerViewDelegate {
        boolean checkInlinePermissions();

        ViewGroup getTextureViewContainer();

        void onInitFailed();

        void onInlineSurfaceTextureReady();

        void onPlayStateChanged(WebPlayerView webPlayerView, boolean z);

        void onSharePressed();

        TextureView onSwitchInlineMode(View view, boolean z, float f, int i, boolean z2);

        TextureView onSwitchToFullscreen(View view, boolean z, float f, int i, boolean z2);

        void onVideoSizeChanged(float f, int i);

        void prepareToSwitchInlineMode(boolean z, Runnable runnable, float f, boolean z2);
    }

    private abstract class function {
        public abstract Object run(Object[] objArr);

        private function() {
        }
    }

    public class JSExtractor {
        private String jsCode;
        ArrayList<String> codeLines = new ArrayList<>();
        private String[] operators = {LogUtils.VERTICAL, "^", "&", ">>", "<<", "-", Marker.ANY_NON_NULL_MARKER, "%", "/", "*"};
        private String[] assign_operators = {"|=", "^=", "&=", ">>=", "<<=", "-=", "+=", "%=", "/=", "*=", "="};

        public JSExtractor(String js) {
            this.jsCode = js;
        }

        private void interpretExpression(String expr, HashMap<String, String> localVars, int allowRecursion) throws Exception {
            String expr2 = expr.trim();
            if (TextUtils.isEmpty(expr2)) {
                return;
            }
            if (expr2.charAt(0) == '(') {
                int parens_count = 0;
                Matcher matcher = WebPlayerView.exprParensPattern.matcher(expr2);
                while (true) {
                    if (!matcher.find()) {
                        break;
                    }
                    String group = matcher.group(0);
                    if (group.indexOf(48) == 40) {
                        parens_count++;
                    } else {
                        parens_count--;
                        if (parens_count == 0) {
                            String sub_expr = expr2.substring(1, matcher.start());
                            interpretExpression(sub_expr, localVars, allowRecursion);
                            String remaining_expr = expr2.substring(matcher.end()).trim();
                            if (TextUtils.isEmpty(remaining_expr)) {
                                return;
                            } else {
                                expr2 = remaining_expr;
                            }
                        }
                    }
                }
                if (parens_count != 0) {
                    throw new Exception(String.format("Premature end of parens in %s", expr2));
                }
            }
            int a = 0;
            while (true) {
                String[] strArr = this.assign_operators;
                if (a < strArr.length) {
                    Matcher matcher2 = Pattern.compile(String.format(Locale.US, "(?x)(%s)(?:\\[([^\\]]+?)\\])?\\s*%s(.*)$", WebPlayerView.exprName, Pattern.quote(strArr[a]))).matcher(expr2);
                    if (!matcher2.find()) {
                        a++;
                    } else {
                        interpretExpression(matcher2.group(3), localVars, allowRecursion - 1);
                        String index = matcher2.group(2);
                        if (!TextUtils.isEmpty(index)) {
                            interpretExpression(index, localVars, allowRecursion);
                            return;
                        } else {
                            localVars.put(matcher2.group(1), "");
                            return;
                        }
                    }
                } else {
                    try {
                        Integer.parseInt(expr2);
                        return;
                    } catch (Exception e) {
                        if (Pattern.compile(String.format(Locale.US, "(?!if|return|true|false)(%s)$", WebPlayerView.exprName)).matcher(expr2).find()) {
                            return;
                        }
                        if (expr2.charAt(0) == '\"' && expr2.charAt(expr2.length() - 1) == '\"') {
                            return;
                        }
                        try {
                            new JSONObject(expr2).toString();
                            return;
                        } catch (Exception e2) {
                            Matcher matcher3 = Pattern.compile(String.format(Locale.US, "(%s)\\[(.+)\\]$", WebPlayerView.exprName)).matcher(expr2);
                            if (matcher3.find()) {
                                matcher3.group(1);
                                interpretExpression(matcher3.group(2), localVars, allowRecursion - 1);
                                return;
                            }
                            Matcher matcher4 = Pattern.compile(String.format(Locale.US, "(%s)(?:\\.([^(]+)|\\[([^]]+)\\])\\s*(?:\\(+([^()]*)\\))?$", WebPlayerView.exprName)).matcher(expr2);
                            if (matcher4.find()) {
                                String variable = matcher4.group(1);
                                String m1 = matcher4.group(2);
                                String m2 = matcher4.group(3);
                                (TextUtils.isEmpty(m1) ? m2 : m1).replace("\"", "");
                                String arg_str = matcher4.group(4);
                                if (localVars.get(variable) == null) {
                                    extractObject(variable);
                                }
                                if (arg_str == null) {
                                    return;
                                }
                                if (expr2.charAt(expr2.length() - 1) != ')') {
                                    throw new Exception("last char not ')'");
                                }
                                if (arg_str.length() != 0) {
                                    String[] args = arg_str.split(",");
                                    for (String str : args) {
                                        interpretExpression(str, localVars, allowRecursion);
                                    }
                                    return;
                                }
                                return;
                            }
                            Matcher matcher5 = Pattern.compile(String.format(Locale.US, "(%s)\\[(.+)\\]$", WebPlayerView.exprName)).matcher(expr2);
                            if (matcher5.find()) {
                                localVars.get(matcher5.group(1));
                                interpretExpression(matcher5.group(2), localVars, allowRecursion - 1);
                                return;
                            }
                            int a2 = 0;
                            while (true) {
                                String[] strArr2 = this.operators;
                                if (a2 < strArr2.length) {
                                    String func = strArr2[a2];
                                    Matcher matcher6 = Pattern.compile(String.format(Locale.US, "(.+?)%s(.+)", Pattern.quote(func))).matcher(expr2);
                                    if (matcher6.find()) {
                                        boolean[] abort = new boolean[1];
                                        interpretStatement(matcher6.group(1), localVars, abort, allowRecursion - 1);
                                        if (abort[0]) {
                                            throw new Exception(String.format("Premature left-side return of %s in %s", func, expr2));
                                        }
                                        interpretStatement(matcher6.group(2), localVars, abort, allowRecursion - 1);
                                        if (abort[0]) {
                                            throw new Exception(String.format("Premature right-side return of %s in %s", func, expr2));
                                        }
                                    }
                                    a2++;
                                } else {
                                    Matcher matcher7 = Pattern.compile(String.format(Locale.US, "^(%s)\\(([a-zA-Z0-9_$,]*)\\)$", WebPlayerView.exprName)).matcher(expr2);
                                    if (matcher7.find()) {
                                        String fname = matcher7.group(1);
                                        extractFunction(fname);
                                    }
                                    throw new Exception(String.format("Unsupported JS expression %s", expr2));
                                }
                            }
                        }
                    }
                }
            }
        }

        private void interpretStatement(String stmt, HashMap<String, String> localVars, boolean[] abort, int allowRecursion) throws Exception {
            String expr;
            if (allowRecursion < 0) {
                throw new Exception("recursion limit reached");
            }
            abort[0] = false;
            String stmt2 = stmt.trim();
            Matcher matcher = WebPlayerView.stmtVarPattern.matcher(stmt2);
            if (!matcher.find()) {
                Matcher matcher2 = WebPlayerView.stmtReturnPattern.matcher(stmt2);
                if (matcher2.find()) {
                    String expr2 = stmt2.substring(matcher2.group(0).length());
                    abort[0] = true;
                    expr = expr2;
                } else {
                    expr = stmt2;
                }
            } else {
                expr = stmt2.substring(matcher.group(0).length());
            }
            interpretExpression(expr, localVars, allowRecursion);
        }

        private HashMap<String, Object> extractObject(String objname) throws Exception {
            HashMap<String, Object> obj = new HashMap<>();
            Matcher matcher = Pattern.compile(String.format(Locale.US, "(?:var\\s+)?%s\\s*=\\s*\\{\\s*((%s\\s*:\\s*function\\(.*?\\)\\s*\\{.*?\\}(?:,\\s*)?)*)\\}\\s*;", Pattern.quote(objname), "(?:[a-zA-Z$0-9]+|\"[a-zA-Z$0-9]+\"|'[a-zA-Z$0-9]+')")).matcher(this.jsCode);
            String fields = null;
            while (true) {
                if (!matcher.find()) {
                    break;
                }
                String code = matcher.group();
                fields = matcher.group(2);
                if (!TextUtils.isEmpty(fields)) {
                    if (!this.codeLines.contains(code)) {
                        this.codeLines.add(matcher.group());
                    }
                }
            }
            Matcher matcher2 = Pattern.compile(String.format("(%s)\\s*:\\s*function\\(([a-z,]+)\\)\\{([^}]+)\\}", "(?:[a-zA-Z$0-9]+|\"[a-zA-Z$0-9]+\"|'[a-zA-Z$0-9]+')")).matcher(fields);
            while (matcher2.find()) {
                String[] argnames = matcher2.group(2).split(",");
                buildFunction(argnames, matcher2.group(3));
            }
            return obj;
        }

        private void buildFunction(String[] argNames, String funcCode) throws Exception {
            HashMap<String, String> localVars = new HashMap<>();
            for (String str : argNames) {
                localVars.put(str, "");
            }
            String[] stmts = funcCode.split(";");
            boolean[] abort = new boolean[1];
            for (String str2 : stmts) {
                interpretStatement(str2, localVars, abort, 100);
                if (abort[0]) {
                    return;
                }
            }
        }

        public String extractFunction(String funcName) {
            try {
                String quote = Pattern.quote(funcName);
                Pattern funcPattern = Pattern.compile(String.format(Locale.US, "(?x)(?:function\\s+%s|[{;,]\\s*%s\\s*=\\s*function|var\\s+%s\\s*=\\s*function)\\s*\\(([^)]*)\\)\\s*\\{([^}]+)\\}", quote, quote, quote));
                Matcher matcher = funcPattern.matcher(this.jsCode);
                if (matcher.find()) {
                    String group = matcher.group();
                    if (!this.codeLines.contains(group)) {
                        this.codeLines.add(group + ";");
                    }
                    buildFunction(matcher.group(1).split(","), matcher.group(2));
                }
            } catch (Exception e) {
                this.codeLines.clear();
                FileLog.e(e);
            }
            return TextUtils.join("", this.codeLines);
        }
    }

    public class JavaScriptInterface {
        private final CallJavaResultInterface callJavaResultInterface;

        public JavaScriptInterface(CallJavaResultInterface callJavaResult) {
            this.callJavaResultInterface = callJavaResult;
        }

        @JavascriptInterface
        public void returnResultToJava(String value) {
            this.callJavaResultInterface.jsCallFinished(value);
        }
    }

    protected String downloadUrlContent(AsyncTask parentTask, String url) {
        return downloadUrlContent(parentTask, url, null, true);
    }

    protected String downloadUrlContent(AsyncTask parentTask, String url, HashMap<String, String> headers, boolean tryGzip) {
        boolean canRetry;
        boolean done;
        StringBuilder result;
        boolean canRetry2;
        boolean done2;
        StringBuilder result2;
        URL downloadUrl;
        URLConnection httpConnection;
        InputStream httpConnectionStream;
        InputStream httpConnectionStream2 = null;
        boolean done3 = false;
        StringBuilder result3 = null;
        URLConnection httpConnection2 = null;
        try {
            try {
                downloadUrl = new URL(url);
                httpConnection2 = downloadUrl.openConnection();
                try {
                    httpConnection2.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)");
                    canRetry = true;
                    if (tryGzip) {
                        try {
                            httpConnection2.addRequestProperty("Accept-Encoding", "gzip, deflate");
                        } catch (Throwable th) {
                            e = th;
                            done = false;
                            result = null;
                            if (e instanceof SocketTimeoutException) {
                            }
                            if (canRetry2) {
                            }
                            if (done2) {
                            }
                        }
                    }
                    try {
                        httpConnection2.addRequestProperty("Accept-Language", "en-us,en;q=0.5");
                        httpConnection2.addRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                        httpConnection2.addRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                        if (headers != null) {
                            try {
                                for (Map.Entry<String, String> entry : headers.entrySet()) {
                                    done = done3;
                                    try {
                                        result = result3;
                                        try {
                                            httpConnection2.addRequestProperty(entry.getKey(), entry.getValue());
                                            done3 = done;
                                            result3 = result;
                                        } catch (Throwable th2) {
                                            e = th2;
                                            if (e instanceof SocketTimeoutException) {
                                                if (ApplicationLoader.isNetworkOnline()) {
                                                    canRetry2 = false;
                                                    FileLog.e(e);
                                                }
                                                canRetry2 = canRetry;
                                                FileLog.e(e);
                                            } else {
                                                boolean canRetry3 = e instanceof UnknownHostException;
                                                if (canRetry3) {
                                                    canRetry2 = false;
                                                } else {
                                                    boolean canRetry4 = e instanceof SocketException;
                                                    if (canRetry4) {
                                                        if (e.getMessage() != null && e.getMessage().contains("ECONNRESET")) {
                                                            canRetry2 = false;
                                                        }
                                                        canRetry2 = canRetry;
                                                    } else {
                                                        boolean canRetry5 = e instanceof FileNotFoundException;
                                                        if (canRetry5) {
                                                            canRetry2 = false;
                                                        }
                                                        canRetry2 = canRetry;
                                                    }
                                                }
                                                FileLog.e(e);
                                            }
                                            if (canRetry2) {
                                            }
                                            if (done2) {
                                            }
                                        }
                                    } catch (Throwable th3) {
                                        e = th3;
                                        result = result3;
                                        if (e instanceof SocketTimeoutException) {
                                        }
                                        if (canRetry2) {
                                        }
                                        if (done2) {
                                        }
                                    }
                                }
                                done = done3;
                                result = result3;
                            } catch (Throwable th4) {
                                e = th4;
                                done = done3;
                                result = result3;
                            }
                        } else {
                            done = false;
                            result = null;
                        }
                        try {
                            httpConnection2.setConnectTimeout(5000);
                            httpConnection2.setReadTimeout(5000);
                        } catch (Throwable th5) {
                            e = th5;
                        }
                    } catch (Throwable th6) {
                        e = th6;
                        done = false;
                        result = null;
                    }
                } catch (Throwable th7) {
                    e = th7;
                    canRetry = true;
                    done = false;
                    result = null;
                }
            } catch (Throwable th8) {
                e = th8;
                canRetry = true;
                done = false;
                result = null;
                if (e instanceof SocketTimeoutException) {
                }
                if (canRetry2) {
                }
                if (done2) {
                }
            }
        } catch (Throwable th9) {
            e = th9;
        }
        if (httpConnection2 instanceof HttpURLConnection) {
            HttpURLConnection httpURLConnection = (HttpURLConnection) httpConnection2;
            httpURLConnection.setInstanceFollowRedirects(true);
            int status = httpURLConnection.getResponseCode();
            httpConnection = httpConnection2;
            if (status == 302 || status == 301 || status == 303) {
                try {
                    String newUrl = httpURLConnection.getHeaderField("Location");
                    String cookies = httpURLConnection.getHeaderField("Set-Cookie");
                    downloadUrl = new URL(newUrl);
                    URLConnection httpConnection3 = downloadUrl.openConnection();
                    try {
                        httpConnection3.setRequestProperty("Cookie", cookies);
                        httpConnection3.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)");
                        if (tryGzip) {
                            httpConnection3.addRequestProperty("Accept-Encoding", "gzip, deflate");
                        }
                        httpConnection3.addRequestProperty("Accept-Language", "en-us,en;q=0.5");
                        httpConnection3.addRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                        httpConnection3.addRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                        if (headers != null) {
                            for (Map.Entry<String, String> entry2 : headers.entrySet()) {
                                httpConnection3.addRequestProperty(entry2.getKey(), entry2.getValue());
                            }
                        }
                        httpConnection2 = httpConnection3;
                        httpConnection2.connect();
                        if (tryGzip) {
                            httpConnectionStream2 = httpConnection2.getInputStream();
                        } else {
                            try {
                                httpConnectionStream = new GZIPInputStream(httpConnection2.getInputStream());
                            } catch (Exception e) {
                                if (0 != 0) {
                                    try {
                                        httpConnectionStream2.close();
                                    } catch (Exception e2) {
                                    }
                                }
                                httpConnection2 = downloadUrl.openConnection();
                                httpConnection2.connect();
                                httpConnectionStream = httpConnection2.getInputStream();
                            }
                            httpConnectionStream2 = httpConnectionStream;
                        }
                        canRetry2 = true;
                    } catch (Throwable th10) {
                        e = th10;
                        httpConnection2 = httpConnection3;
                        if (e instanceof SocketTimeoutException) {
                        }
                        if (canRetry2) {
                        }
                        if (done2) {
                        }
                    }
                } catch (Throwable th11) {
                    e = th11;
                    httpConnection2 = httpConnection;
                }
                if (canRetry2) {
                    try {
                        if (httpConnection2 instanceof HttpURLConnection) {
                            int code = ((HttpURLConnection) httpConnection2).getResponseCode();
                            if (code != 200) {
                            }
                        }
                    } catch (Exception e3) {
                        FileLog.e(e3);
                    }
                    if (httpConnectionStream2 != null) {
                        try {
                            byte[] data = new byte[32768];
                            result2 = result;
                            while (true) {
                                try {
                                    if (parentTask.isCancelled()) {
                                        break;
                                    }
                                    try {
                                        int read = httpConnectionStream2.read(data);
                                        if (read > 0) {
                                            if (result2 == null) {
                                                result2 = new StringBuilder();
                                            }
                                            result2.append(new String(data, 0, read, StandardCharsets.UTF_8));
                                        } else if (read == -1) {
                                            done2 = true;
                                        }
                                    } catch (Exception e4) {
                                        FileLog.e(e4);
                                        done2 = done;
                                    }
                                } catch (Throwable th12) {
                                    e = th12;
                                    FileLog.e(e);
                                    done2 = done;
                                    if (httpConnectionStream2 != null) {
                                    }
                                    if (done2) {
                                    }
                                }
                            }
                            done2 = done;
                        } catch (Throwable th13) {
                            e = th13;
                            result2 = result;
                        }
                    } else {
                        done2 = done;
                        result2 = result;
                    }
                    if (httpConnectionStream2 != null) {
                        try {
                            httpConnectionStream2.close();
                        } catch (Throwable e5) {
                            FileLog.e(e5);
                        }
                    }
                } else {
                    done2 = done;
                    result2 = result;
                }
                if (done2) {
                    return null;
                }
                return result2.toString();
            }
        } else {
            httpConnection = httpConnection2;
        }
        httpConnection2 = httpConnection;
        httpConnection2.connect();
        if (tryGzip) {
        }
        canRetry2 = true;
        if (canRetry2) {
        }
        if (done2) {
        }
    }

    public class YoutubeVideoTask extends AsyncTask<Void, Void, String[]> {
        private boolean canRetry = true;
        private CountDownLatch countDownLatch = new CountDownLatch(1);
        private String[] result = new String[2];
        private String sig;
        private String videoId;

        public YoutubeVideoTask(String vid) {
            this.videoId = vid;
        }

        @Override
        public String[] doInBackground(Void... voids) {
            boolean encrypted;
            boolean encrypted2;
            String jsUrl;
            String playerId;
            String functionCode;
            String functionName;
            String functionCode2;
            String params;
            String[] extra;
            String params2;
            String[] extra2;
            boolean encrypted3;
            String embedCode = WebPlayerView.this.downloadUrlContent(this, "https://www.youtube.com/embed/" + this.videoId);
            String[] strArr = null;
            if (!isCancelled()) {
                String params3 = "video_id=" + this.videoId + "&ps=default&gl=US&hl=en";
                try {
                    params3 = params3 + "&eurl=" + URLEncoder.encode("https://youtube.googleapis.com/v/" + this.videoId, "UTF-8");
                } catch (Exception e) {
                    FileLog.e(e);
                }
                if (embedCode != null) {
                    Matcher matcher = WebPlayerView.stsPattern.matcher(embedCode);
                    if (matcher.find()) {
                        params3 = params3 + "&sts=" + embedCode.substring(matcher.start() + 6, matcher.end());
                    } else {
                        params3 = params3 + "&sts=";
                    }
                }
                this.result[1] = DownloadAction.TYPE_DASH;
                encrypted = false;
                String otherUrl = null;
                String[] extra3 = {"", "&el=leanback", "&el=embedded", "&el=detailpage", "&el=vevo"};
                int i = 0;
                while (true) {
                    int i2 = 2;
                    if (i >= extra3.length) {
                        break;
                    }
                    String videoInfo = WebPlayerView.this.downloadUrlContent(this, "https://www.youtube.com/get_video_info?" + params3 + extra3[i]);
                    if (isCancelled()) {
                        return strArr;
                    }
                    boolean exists = false;
                    String hls = null;
                    boolean isLive = false;
                    if (videoInfo == null) {
                        params = params3;
                        extra = extra3;
                    } else {
                        String[] args = videoInfo.split("&");
                        int a = 0;
                        boolean isLive2 = false;
                        String hls2 = null;
                        boolean exists2 = false;
                        String otherUrl2 = otherUrl;
                        boolean encrypted4 = encrypted;
                        while (a < args.length) {
                            if (args[a].startsWith("dashmpd")) {
                                exists2 = true;
                                String[] args2 = args[a].split("=");
                                if (args2.length == i2) {
                                    try {
                                        this.result[0] = URLDecoder.decode(args2[1], "UTF-8");
                                    } catch (Exception e2) {
                                        FileLog.e(e2);
                                    }
                                }
                                params2 = params3;
                                extra2 = extra3;
                            } else if (args[a].startsWith("url_encoded_fmt_stream_map")) {
                                String[] args22 = args[a].split("=");
                                params2 = params3;
                                if (args22.length != 2) {
                                    encrypted3 = encrypted4;
                                    extra2 = extra3;
                                } else {
                                    try {
                                        String[] args3 = URLDecoder.decode(args22[1], "UTF-8").split("[&,]");
                                        boolean isMp4 = false;
                                        String currentUrl = null;
                                        int c = 0;
                                        while (true) {
                                            encrypted3 = encrypted4;
                                            try {
                                                if (c >= args3.length) {
                                                    extra2 = extra3;
                                                    break;
                                                }
                                                String[] args4 = args3[c].split("=");
                                                String[] args32 = args3;
                                                extra2 = extra3;
                                                try {
                                                    if (args4[0].startsWith("type")) {
                                                        String type = URLDecoder.decode(args4[1], "UTF-8");
                                                        if (type.contains(MimeTypes.VIDEO_MP4)) {
                                                            isMp4 = true;
                                                        }
                                                    } else if (args4[0].startsWith(ImagesContract.URL)) {
                                                        currentUrl = URLDecoder.decode(args4[1], "UTF-8");
                                                    } else if (args4[0].startsWith("itag")) {
                                                        currentUrl = null;
                                                        isMp4 = false;
                                                    }
                                                    if (!isMp4 || currentUrl == null) {
                                                        c++;
                                                        encrypted4 = encrypted3;
                                                        args3 = args32;
                                                        extra3 = extra2;
                                                    } else {
                                                        String otherUrl3 = currentUrl;
                                                        otherUrl2 = otherUrl3;
                                                        break;
                                                    }
                                                } catch (Exception e3) {
                                                    e = e3;
                                                    FileLog.e(e);
                                                    encrypted4 = encrypted3;
                                                    a++;
                                                    params3 = params2;
                                                    extra3 = extra2;
                                                    i2 = 2;
                                                }
                                            } catch (Exception e4) {
                                                e = e4;
                                                extra2 = extra3;
                                            }
                                        }
                                    } catch (Exception e5) {
                                        e = e5;
                                        encrypted3 = encrypted4;
                                        extra2 = extra3;
                                    }
                                }
                                encrypted4 = encrypted3;
                            } else {
                                params2 = params3;
                                boolean encrypted5 = encrypted4;
                                extra2 = extra3;
                                if (args[a].startsWith("use_cipher_signature")) {
                                    String[] args23 = args[a].split("=");
                                    if (args23.length == 2 && args23[1].toLowerCase().equals("true")) {
                                        encrypted4 = true;
                                    } else {
                                        encrypted4 = encrypted5;
                                    }
                                } else if (!args[a].startsWith("hlsvp")) {
                                    if (args[a].startsWith("livestream")) {
                                        String[] args24 = args[a].split("=");
                                        if (args24.length == 2 && args24[1].toLowerCase().equals("1")) {
                                            isLive2 = true;
                                            encrypted4 = encrypted5;
                                        }
                                    }
                                    encrypted4 = encrypted5;
                                } else {
                                    String[] args25 = args[a].split("=");
                                    if (args25.length == 2) {
                                        try {
                                            String hls3 = URLDecoder.decode(args25[1], "UTF-8");
                                            hls2 = hls3;
                                        } catch (Exception e6) {
                                            FileLog.e(e6);
                                        }
                                    }
                                    encrypted4 = encrypted5;
                                }
                            }
                            a++;
                            params3 = params2;
                            extra3 = extra2;
                            i2 = 2;
                        }
                        params = params3;
                        boolean encrypted6 = encrypted4;
                        extra = extra3;
                        otherUrl = otherUrl2;
                        exists = exists2;
                        hls = hls2;
                        isLive = isLive2;
                        encrypted = encrypted6;
                    }
                    if (isLive) {
                        if (hls == null || encrypted || hls.contains("/s/")) {
                            return null;
                        }
                        String[] strArr2 = this.result;
                        strArr2[0] = hls;
                        strArr2[1] = DownloadAction.TYPE_HLS;
                    }
                    if (exists) {
                        break;
                    }
                    i++;
                    params3 = params;
                    extra3 = extra;
                    strArr = null;
                }
            } else {
                return null;
            }
            if (!TextUtils.isEmpty(functionCode)) {
                if (Build.VERSION.SDK_INT >= 21) {
                    functionCode2 = functionCode + functionName + "('" + this.sig.substring(3) + "');";
                } else {
                    functionCode2 = functionCode + "window." + WebPlayerView.this.interfaceName + ".returnResultToJava(" + functionName + "('" + this.sig.substring(3) + "'));";
                }
                final String functionCodeFinal = functionCode2;
                try {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            WebPlayerView.YoutubeVideoTask.this.lambda$doInBackground$1$WebPlayerView$YoutubeVideoTask(functionCodeFinal);
                        }
                    });
                    this.countDownLatch.await();
                    encrypted = false;
                } catch (Exception e7) {
                    FileLog.e(e7);
                    encrypted = true;
                    encrypted2 = isCancelled();
                    if (!encrypted2 || encrypted) {
                        return null;
                    }
                    return this.result;
                }
                encrypted2 = isCancelled();
                if (encrypted2) {
                }
                return null;
            }
            encrypted = true;
            encrypted2 = isCancelled();
            if (encrypted2) {
            }
            return null;
            if (jsUrl != null) {
                Matcher matcher2 = WebPlayerView.playerIdPattern.matcher(jsUrl);
                if (matcher2.find()) {
                    playerId = matcher2.group(1) + matcher2.group(2);
                } else {
                    playerId = null;
                }
                functionCode = null;
                String functionName2 = null;
                SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("youtubecode", 0);
                if (playerId != null) {
                    functionCode = preferences.getString(playerId, null);
                    functionName2 = preferences.getString(playerId + "n", null);
                }
                if (functionCode != null) {
                    functionName = functionName2;
                } else {
                    if (jsUrl.startsWith("//")) {
                        jsUrl = "https:" + jsUrl;
                    } else if (jsUrl.startsWith("/")) {
                        jsUrl = "https://www.youtube.com" + jsUrl;
                    }
                    String jsCode = WebPlayerView.this.downloadUrlContent(this, jsUrl);
                    if (isCancelled()) {
                        return null;
                    }
                    if (jsCode != null) {
                        Matcher matcher3 = WebPlayerView.sigPattern.matcher(jsCode);
                        if (!matcher3.find()) {
                            Matcher matcher4 = WebPlayerView.sigPattern2.matcher(jsCode);
                            if (!matcher4.find()) {
                                functionName = functionName2;
                            } else {
                                String functionName3 = matcher4.group(1);
                                functionName = functionName3;
                            }
                        } else {
                            String functionName4 = matcher3.group(1);
                            functionName = functionName4;
                        }
                        if (functionName != null) {
                            try {
                                JSExtractor extractor = new JSExtractor(jsCode);
                                functionCode = extractor.extractFunction(functionName);
                                if (!TextUtils.isEmpty(functionCode) && playerId != null) {
                                    preferences.edit().putString(playerId, functionCode).putString(playerId + "n", functionName).commit();
                                }
                            } catch (Exception e8) {
                                FileLog.e(e8);
                            }
                        }
                    } else {
                        functionName = functionName2;
                    }
                }
                if (!TextUtils.isEmpty(functionCode)) {
                }
            }
            encrypted = true;
            encrypted2 = isCancelled();
            if (encrypted2) {
            }
            return null;
        }

        public void lambda$doInBackground$1$WebPlayerView$YoutubeVideoTask(String functionCodeFinal) {
            if (Build.VERSION.SDK_INT >= 21) {
                WebPlayerView.this.webView.evaluateJavascript(functionCodeFinal, new ValueCallback() {
                    @Override
                    public final void onReceiveValue(Object obj) {
                        WebPlayerView.YoutubeVideoTask.this.lambda$null$0$WebPlayerView$YoutubeVideoTask((String) obj);
                    }
                });
                return;
            }
            try {
                String javascript = "<script>" + functionCodeFinal + "</script>";
                byte[] data = javascript.getBytes(StandardCharsets.UTF_8);
                String base64 = Base64.encodeToString(data, 0);
                WebPlayerView.this.webView.loadUrl("data:text/html;charset=utf-8;base64," + base64);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }

        public void lambda$null$0$WebPlayerView$YoutubeVideoTask(String value) {
            String[] strArr = this.result;
            strArr[0] = strArr[0].replace(this.sig, "/signature/" + value.substring(1, value.length() - 1));
            this.countDownLatch.countDown();
        }

        public void onInterfaceResult(String value) {
            String[] strArr = this.result;
            strArr[0] = strArr[0].replace(this.sig, "/signature/" + value);
            this.countDownLatch.countDown();
        }

        @Override
        public void onPostExecute(String[] result) {
            if (result[0] != null) {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("start play youtube video " + result[1] + " " + result[0]);
                }
                WebPlayerView.this.initied = true;
                WebPlayerView.this.playVideoUrl = result[0];
                WebPlayerView.this.playVideoType = result[1];
                if (WebPlayerView.this.playVideoType.equals(DownloadAction.TYPE_HLS)) {
                    WebPlayerView.this.isStream = true;
                }
                if (WebPlayerView.this.isAutoplay) {
                    WebPlayerView.this.preparePlayer();
                }
                WebPlayerView.this.showProgress(false, true);
                WebPlayerView.this.controlsView.show(true, true);
                return;
            }
            if (!isCancelled()) {
                WebPlayerView.this.onInitFailed();
            }
        }
    }

    public class VimeoVideoTask extends AsyncTask<Void, Void, String> {
        private boolean canRetry = true;
        private String[] results = new String[2];
        private String videoId;

        public VimeoVideoTask(String vid) {
            this.videoId = vid;
        }

        @Override
        public String doInBackground(Void... voids) {
            String playerCode = WebPlayerView.this.downloadUrlContent(this, String.format(Locale.US, "https://player.vimeo.com/video/%s/config", this.videoId));
            if (isCancelled()) {
                return null;
            }
            try {
                JSONObject json = new JSONObject(playerCode);
                JSONObject files = json.getJSONObject("request").getJSONObject("files");
                if (files.has(DownloadAction.TYPE_HLS)) {
                    JSONObject hls = files.getJSONObject(DownloadAction.TYPE_HLS);
                    try {
                        this.results[0] = hls.getString(ImagesContract.URL);
                    } catch (Exception e) {
                        String defaultCdn = hls.getString("default_cdn");
                        JSONObject cdns = hls.getJSONObject("cdns");
                        this.results[0] = cdns.getJSONObject(defaultCdn).getString(ImagesContract.URL);
                    }
                    this.results[1] = DownloadAction.TYPE_HLS;
                } else if (files.has(DownloadAction.TYPE_PROGRESSIVE)) {
                    this.results[1] = "other";
                    JSONArray progressive = files.getJSONArray(DownloadAction.TYPE_PROGRESSIVE);
                    JSONObject format = progressive.getJSONObject(0);
                    this.results[0] = format.getString(ImagesContract.URL);
                }
            } catch (Exception e2) {
                FileLog.e(e2);
            }
            if (isCancelled()) {
                return null;
            }
            return this.results[0];
        }

        @Override
        public void onPostExecute(String result) {
            if (result != null) {
                WebPlayerView.this.initied = true;
                WebPlayerView.this.playVideoUrl = result;
                WebPlayerView.this.playVideoType = this.results[1];
                if (WebPlayerView.this.isAutoplay) {
                    WebPlayerView.this.preparePlayer();
                }
                WebPlayerView.this.showProgress(false, true);
                WebPlayerView.this.controlsView.show(true, true);
                return;
            }
            if (!isCancelled()) {
                WebPlayerView.this.onInitFailed();
            }
        }
    }

    public class AparatVideoTask extends AsyncTask<Void, Void, String> {
        private boolean canRetry = true;
        private String[] results = new String[2];
        private String videoId;

        public AparatVideoTask(String vid) {
            this.videoId = vid;
        }

        @Override
        public String doInBackground(Void... voids) {
            String playerCode = WebPlayerView.this.downloadUrlContent(this, String.format(Locale.US, "http://www.aparat.com/video/video/embed/vt/frame/showvideo/yes/videohash/%s", this.videoId));
            if (isCancelled()) {
                return null;
            }
            try {
                Matcher filelist = WebPlayerView.aparatFileListPattern.matcher(playerCode);
                if (filelist.find()) {
                    String jsonCode = filelist.group(1);
                    JSONArray json = new JSONArray(jsonCode);
                    for (int a = 0; a < json.length(); a++) {
                        JSONArray array = json.getJSONArray(a);
                        if (array.length() != 0) {
                            JSONObject object = array.getJSONObject(0);
                            if (object.has("file")) {
                                this.results[0] = object.getString("file");
                                this.results[1] = "other";
                            }
                        }
                    }
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (isCancelled()) {
                return null;
            }
            return this.results[0];
        }

        @Override
        public void onPostExecute(String result) {
            if (result != null) {
                WebPlayerView.this.initied = true;
                WebPlayerView.this.playVideoUrl = result;
                WebPlayerView.this.playVideoType = this.results[1];
                if (WebPlayerView.this.isAutoplay) {
                    WebPlayerView.this.preparePlayer();
                }
                WebPlayerView.this.showProgress(false, true);
                WebPlayerView.this.controlsView.show(true, true);
                return;
            }
            if (!isCancelled()) {
                WebPlayerView.this.onInitFailed();
            }
        }
    }

    public class TwitchClipVideoTask extends AsyncTask<Void, Void, String> {
        private String currentUrl;
        private String videoId;
        private boolean canRetry = true;
        private String[] results = new String[2];

        public TwitchClipVideoTask(String url, String vid) {
            this.videoId = vid;
            this.currentUrl = url;
        }

        @Override
        public String doInBackground(Void... voids) {
            String playerCode = WebPlayerView.this.downloadUrlContent(this, this.currentUrl, null, false);
            if (isCancelled()) {
                return null;
            }
            try {
                Matcher filelist = WebPlayerView.twitchClipFilePattern.matcher(playerCode);
                if (filelist.find()) {
                    String jsonCode = filelist.group(1);
                    JSONObject json = new JSONObject(jsonCode);
                    JSONArray array = json.getJSONArray("quality_options");
                    JSONObject obj = array.getJSONObject(0);
                    this.results[0] = obj.getString("source");
                    this.results[1] = "other";
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (isCancelled()) {
                return null;
            }
            return this.results[0];
        }

        @Override
        public void onPostExecute(String result) {
            if (result != null) {
                WebPlayerView.this.initied = true;
                WebPlayerView.this.playVideoUrl = result;
                WebPlayerView.this.playVideoType = this.results[1];
                if (WebPlayerView.this.isAutoplay) {
                    WebPlayerView.this.preparePlayer();
                }
                WebPlayerView.this.showProgress(false, true);
                WebPlayerView.this.controlsView.show(true, true);
                return;
            }
            if (!isCancelled()) {
                WebPlayerView.this.onInitFailed();
            }
        }
    }

    public class TwitchStreamVideoTask extends AsyncTask<Void, Void, String> {
        private String currentUrl;
        private String videoId;
        private boolean canRetry = true;
        private String[] results = new String[2];

        public TwitchStreamVideoTask(String url, String vid) {
            this.videoId = vid;
            this.currentUrl = url;
        }

        @Override
        public String doInBackground(Void... voids) {
            HashMap<String, String> headers = new HashMap<>();
            headers.put("Client-ID", "jzkbprff40iqj646a697cyrvl0zt2m6");
            int idx = this.videoId.indexOf(38);
            if (idx > 0) {
                this.videoId = this.videoId.substring(0, idx);
            }
            String streamCode = WebPlayerView.this.downloadUrlContent(this, String.format(Locale.US, "https://api.twitch.tv/kraken/streams/%s?stream_type=all", this.videoId), headers, false);
            if (isCancelled()) {
                return null;
            }
            try {
                JSONObject obj = new JSONObject(streamCode);
                obj.getJSONObject("stream");
                String accessTokenCode = WebPlayerView.this.downloadUrlContent(this, String.format(Locale.US, "https://api.twitch.tv/api/channels/%s/access_token", this.videoId), headers, false);
                JSONObject accessToken = new JSONObject(accessTokenCode);
                String sig = URLEncoder.encode(accessToken.getString("sig"), "UTF-8");
                String token = URLEncoder.encode(accessToken.getString("token"), "UTF-8");
                URLEncoder.encode("https://youtube.googleapis.com/v/" + this.videoId, "UTF-8");
                String params = "allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&segment_preference=4&p=" + ((int) (Math.random() * 1.0E7d)) + "&sig=" + sig + "&token=" + token;
                String m3uUrl = String.format(Locale.US, "https://usher.ttvnw.net/api/channel/hls/%s.m3u8?%s", this.videoId, params);
                this.results[0] = m3uUrl;
                this.results[1] = DownloadAction.TYPE_HLS;
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (isCancelled()) {
                return null;
            }
            return this.results[0];
        }

        @Override
        public void onPostExecute(String result) {
            if (result != null) {
                WebPlayerView.this.initied = true;
                WebPlayerView.this.playVideoUrl = result;
                WebPlayerView.this.playVideoType = this.results[1];
                if (WebPlayerView.this.isAutoplay) {
                    WebPlayerView.this.preparePlayer();
                }
                WebPlayerView.this.showProgress(false, true);
                WebPlayerView.this.controlsView.show(true, true);
                return;
            }
            if (!isCancelled()) {
                WebPlayerView.this.onInitFailed();
            }
        }
    }

    public class CoubVideoTask extends AsyncTask<Void, Void, String> {
        private boolean canRetry = true;
        private String[] results = new String[4];
        private String videoId;

        public CoubVideoTask(String vid) {
            this.videoId = vid;
        }

        private String decodeUrl(String input) {
            StringBuilder source = new StringBuilder(input);
            for (int a = 0; a < source.length(); a++) {
                char c = source.charAt(a);
                char lower = Character.toLowerCase(c);
                source.setCharAt(a, c == lower ? Character.toUpperCase(c) : lower);
            }
            try {
                return new String(Base64.decode(source.toString(), 0), StandardCharsets.UTF_8);
            } catch (Exception e) {
                return null;
            }
        }

        @Override
        public String doInBackground(Void... voids) {
            String playerCode = WebPlayerView.this.downloadUrlContent(this, String.format(Locale.US, "https://coub.com/api/v2/coubs/%s.json", this.videoId));
            if (isCancelled()) {
                return null;
            }
            try {
                JSONObject json = new JSONObject(playerCode).getJSONObject("file_versions").getJSONObject("mobile");
                String video = decodeUrl(json.getString("gifv"));
                String audio = json.getJSONArray(MimeTypes.BASE_TYPE_AUDIO).getString(0);
                if (video != null && audio != null) {
                    this.results[0] = video;
                    this.results[1] = "other";
                    this.results[2] = audio;
                    this.results[3] = "other";
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (isCancelled()) {
                return null;
            }
            return this.results[0];
        }

        @Override
        public void onPostExecute(String result) {
            if (result != null) {
                WebPlayerView.this.initied = true;
                WebPlayerView.this.playVideoUrl = result;
                WebPlayerView.this.playVideoType = this.results[1];
                WebPlayerView.this.playAudioUrl = this.results[2];
                WebPlayerView.this.playAudioType = this.results[3];
                if (WebPlayerView.this.isAutoplay) {
                    WebPlayerView.this.preparePlayer();
                }
                WebPlayerView.this.showProgress(false, true);
                WebPlayerView.this.controlsView.show(true, true);
                return;
            }
            if (!isCancelled()) {
                WebPlayerView.this.onInitFailed();
            }
        }
    }

    public class ControlsView extends FrameLayout {
        private int bufferedPosition;
        private AnimatorSet currentAnimation;
        private int currentProgressX;
        private int duration;
        private StaticLayout durationLayout;
        private int durationWidth;
        private Runnable hideRunnable;
        private ImageReceiver imageReceiver;
        private boolean isVisible;
        private int lastProgressX;
        private int progress;
        private Paint progressBufferedPaint;
        private Paint progressInnerPaint;
        private StaticLayout progressLayout;
        private Paint progressPaint;
        private boolean progressPressed;
        private TextPaint textPaint;

        public void lambda$new$0$WebPlayerView$ControlsView() {
            show(false, true);
        }

        public ControlsView(Context context) {
            super(context);
            this.isVisible = true;
            this.hideRunnable = new Runnable() {
                @Override
                public final void run() {
                    WebPlayerView.ControlsView.this.lambda$new$0$WebPlayerView$ControlsView();
                }
            };
            setWillNotDraw(false);
            TextPaint textPaint = new TextPaint(1);
            this.textPaint = textPaint;
            textPaint.setColor(-1);
            this.textPaint.setTextSize(AndroidUtilities.dp(12.0f));
            Paint paint = new Paint(1);
            this.progressPaint = paint;
            paint.setColor(-15095832);
            Paint paint2 = new Paint();
            this.progressInnerPaint = paint2;
            paint2.setColor(-6975081);
            Paint paint3 = new Paint(1);
            this.progressBufferedPaint = paint3;
            paint3.setColor(-1);
            this.imageReceiver = new ImageReceiver(this);
        }

        public void setDuration(int value) {
            if (this.duration == value || value < 0 || WebPlayerView.this.isStream) {
                return;
            }
            this.duration = value;
            StaticLayout staticLayout = new StaticLayout(String.format(Locale.US, "%d:%02d", Integer.valueOf(this.duration / 60), Integer.valueOf(this.duration % 60)), this.textPaint, AndroidUtilities.dp(1000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
            this.durationLayout = staticLayout;
            if (staticLayout.getLineCount() > 0) {
                this.durationWidth = (int) Math.ceil(this.durationLayout.getLineWidth(0));
            }
            invalidate();
        }

        public void setBufferedProgress(int position) {
            this.bufferedPosition = position;
            invalidate();
        }

        public void setProgress(int value) {
            if (this.progressPressed || value < 0 || WebPlayerView.this.isStream) {
                return;
            }
            this.progress = value;
            this.progressLayout = new StaticLayout(String.format(Locale.US, "%d:%02d", Integer.valueOf(this.progress / 60), Integer.valueOf(this.progress % 60)), this.textPaint, AndroidUtilities.dp(1000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
            invalidate();
        }

        public void show(boolean value, boolean animated) {
            if (this.isVisible == value) {
                return;
            }
            this.isVisible = value;
            AnimatorSet animatorSet = this.currentAnimation;
            if (animatorSet != null) {
                animatorSet.cancel();
            }
            if (this.isVisible) {
                if (animated) {
                    AnimatorSet animatorSet2 = new AnimatorSet();
                    this.currentAnimation = animatorSet2;
                    animatorSet2.playTogether(ObjectAnimator.ofFloat(this, "alpha", 1.0f));
                    this.currentAnimation.setDuration(150L);
                    this.currentAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animator) {
                            ControlsView.this.currentAnimation = null;
                        }
                    });
                    this.currentAnimation.start();
                } else {
                    setAlpha(1.0f);
                }
            } else if (animated) {
                AnimatorSet animatorSet3 = new AnimatorSet();
                this.currentAnimation = animatorSet3;
                animatorSet3.playTogether(ObjectAnimator.ofFloat(this, "alpha", 0.0f));
                this.currentAnimation.setDuration(150L);
                this.currentAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        ControlsView.this.currentAnimation = null;
                    }
                });
                this.currentAnimation.start();
            } else {
                setAlpha(0.0f);
            }
            checkNeedHide();
        }

        public void checkNeedHide() {
            AndroidUtilities.cancelRunOnUIThread(this.hideRunnable);
            if (this.isVisible && WebPlayerView.this.videoPlayer.isPlaying()) {
                AndroidUtilities.runOnUIThread(this.hideRunnable, 3000L);
            }
        }

        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            if (ev.getAction() == 0) {
                if (!this.isVisible) {
                    show(true, true);
                    return true;
                }
                onTouchEvent(ev);
                return this.progressPressed;
            }
            return super.onInterceptTouchEvent(ev);
        }

        @Override
        public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
            super.requestDisallowInterceptTouchEvent(disallowIntercept);
            checkNeedHide();
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            int progressLineX;
            int progressLineEndX;
            int progressY;
            if (WebPlayerView.this.inFullscreen) {
                progressLineX = AndroidUtilities.dp(36.0f) + this.durationWidth;
                progressLineEndX = (getMeasuredWidth() - AndroidUtilities.dp(76.0f)) - this.durationWidth;
                progressY = getMeasuredHeight() - AndroidUtilities.dp(28.0f);
            } else {
                progressLineX = 0;
                progressLineEndX = getMeasuredWidth();
                progressY = getMeasuredHeight() - AndroidUtilities.dp(12.0f);
            }
            int i = this.duration;
            int progressX = (i != 0 ? (int) ((progressLineEndX - progressLineX) * (this.progress / i)) : 0) + progressLineX;
            if (event.getAction() == 0) {
                if (this.isVisible && !WebPlayerView.this.isInline && !WebPlayerView.this.isStream) {
                    if (this.duration != 0) {
                        int x = (int) event.getX();
                        int y = (int) event.getY();
                        if (x >= progressX - AndroidUtilities.dp(10.0f) && x <= AndroidUtilities.dp(10.0f) + progressX && y >= progressY - AndroidUtilities.dp(10.0f) && y <= AndroidUtilities.dp(10.0f) + progressY) {
                            this.progressPressed = true;
                            this.lastProgressX = x;
                            this.currentProgressX = progressX;
                            getParent().requestDisallowInterceptTouchEvent(true);
                            invalidate();
                        }
                    }
                } else {
                    show(true, true);
                }
                AndroidUtilities.cancelRunOnUIThread(this.hideRunnable);
            } else if (event.getAction() == 1 || event.getAction() == 3) {
                if (WebPlayerView.this.initied && WebPlayerView.this.videoPlayer.isPlaying()) {
                    AndroidUtilities.runOnUIThread(this.hideRunnable, 3000L);
                }
                if (this.progressPressed) {
                    this.progressPressed = false;
                    if (WebPlayerView.this.initied) {
                        this.progress = (int) (this.duration * ((this.currentProgressX - progressLineX) / (progressLineEndX - progressLineX)));
                        WebPlayerView.this.videoPlayer.seekTo(this.progress * 1000);
                    }
                }
            } else if (event.getAction() == 2 && this.progressPressed) {
                int x2 = (int) event.getX();
                int i2 = this.currentProgressX - (this.lastProgressX - x2);
                this.currentProgressX = i2;
                this.lastProgressX = x2;
                if (i2 < progressLineX) {
                    this.currentProgressX = progressLineX;
                } else if (i2 > progressLineEndX) {
                    this.currentProgressX = progressLineEndX;
                }
                setProgress((int) (this.duration * 1000 * ((this.currentProgressX - progressLineX) / (progressLineEndX - progressLineX))));
                invalidate();
            }
            super.onTouchEvent(event);
            return true;
        }

        @Override
        protected void onDraw(Canvas canvas) {
            int progressLineY;
            int progressLineX;
            int progressLineEndX;
            int cy;
            int progressX;
            int progressX2;
            int i;
            if (WebPlayerView.this.drawImage) {
                if (WebPlayerView.this.firstFrameRendered && WebPlayerView.this.currentAlpha != 0.0f) {
                    long newTime = System.currentTimeMillis();
                    long dt = newTime - WebPlayerView.this.lastUpdateTime;
                    WebPlayerView.this.lastUpdateTime = newTime;
                    WebPlayerView.this.currentAlpha -= ((float) dt) / 150.0f;
                    if (WebPlayerView.this.currentAlpha < 0.0f) {
                        WebPlayerView.this.currentAlpha = 0.0f;
                    }
                    invalidate();
                }
                this.imageReceiver.setAlpha(WebPlayerView.this.currentAlpha);
                this.imageReceiver.draw(canvas);
            }
            if (WebPlayerView.this.videoPlayer.isPlayerPrepared() && !WebPlayerView.this.isStream) {
                int width = getMeasuredWidth();
                int height = getMeasuredHeight();
                if (!WebPlayerView.this.isInline) {
                    if (this.durationLayout != null) {
                        canvas.save();
                        canvas.translate((width - AndroidUtilities.dp(58.0f)) - this.durationWidth, height - AndroidUtilities.dp((WebPlayerView.this.inFullscreen ? 6 : 10) + 29));
                        this.durationLayout.draw(canvas);
                        canvas.restore();
                    }
                    if (this.progressLayout != null) {
                        canvas.save();
                        canvas.translate(AndroidUtilities.dp(18.0f), height - AndroidUtilities.dp((WebPlayerView.this.inFullscreen ? 6 : 10) + 29));
                        this.progressLayout.draw(canvas);
                        canvas.restore();
                    }
                }
                if (this.duration != 0) {
                    if (!WebPlayerView.this.isInline) {
                        if (WebPlayerView.this.inFullscreen) {
                            int progressLineY2 = height - AndroidUtilities.dp(29.0f);
                            int progressLineX2 = AndroidUtilities.dp(36.0f) + this.durationWidth;
                            int progressLineEndX2 = (width - AndroidUtilities.dp(76.0f)) - this.durationWidth;
                            progressLineY = progressLineY2;
                            progressLineX = progressLineX2;
                            progressLineEndX = progressLineEndX2;
                            cy = height - AndroidUtilities.dp(28.0f);
                        } else {
                            int progressLineY3 = height - AndroidUtilities.dp(13.0f);
                            progressLineY = progressLineY3;
                            progressLineX = 0;
                            progressLineEndX = width;
                            cy = height - AndroidUtilities.dp(12.0f);
                        }
                    } else {
                        int progressLineY4 = height - AndroidUtilities.dp(3.0f);
                        progressLineY = progressLineY4;
                        progressLineX = 0;
                        progressLineEndX = width;
                        cy = height - AndroidUtilities.dp(7.0f);
                    }
                    if (WebPlayerView.this.inFullscreen) {
                        canvas.drawRect(progressLineX, progressLineY, progressLineEndX, AndroidUtilities.dp(3.0f) + progressLineY, this.progressInnerPaint);
                    }
                    if (this.progressPressed) {
                        progressX = this.currentProgressX;
                    } else {
                        int progressX3 = progressLineEndX - progressLineX;
                        progressX = ((int) (progressX3 * (this.progress / this.duration))) + progressLineX;
                    }
                    int i2 = this.bufferedPosition;
                    if (i2 != 0 && (i = this.duration) != 0) {
                        progressX2 = progressX;
                        canvas.drawRect(progressLineX, progressLineY, progressLineX + ((progressLineEndX - progressLineX) * (i2 / i)), AndroidUtilities.dp(3.0f) + progressLineY, WebPlayerView.this.inFullscreen ? this.progressBufferedPaint : this.progressInnerPaint);
                    } else {
                        progressX2 = progressX;
                    }
                    canvas.drawRect(progressLineX, progressLineY, progressX2, AndroidUtilities.dp(3.0f) + progressLineY, this.progressPaint);
                    if (!WebPlayerView.this.isInline) {
                        canvas.drawCircle(progressX2, cy, AndroidUtilities.dp(this.progressPressed ? 7.0f : 5.0f), this.progressPaint);
                    }
                }
            }
        }
    }

    public WebPlayerView(Context context, boolean allowInline, boolean allowShare, WebPlayerViewDelegate webPlayerViewDelegate) {
        super(context);
        int i = lastContainerId;
        lastContainerId = i + 1;
        this.fragment_container_id = i;
        this.allowInlineAnimation = Build.VERSION.SDK_INT >= 21;
        this.backgroundPaint = new Paint();
        this.progressRunnable = new Runnable() {
            @Override
            public void run() {
                if (WebPlayerView.this.videoPlayer != null && WebPlayerView.this.videoPlayer.isPlaying()) {
                    WebPlayerView.this.controlsView.setProgress((int) (WebPlayerView.this.videoPlayer.getCurrentPosition() / 1000));
                    WebPlayerView.this.controlsView.setBufferedProgress((int) (WebPlayerView.this.videoPlayer.getBufferedPosition() / 1000));
                    AndroidUtilities.runOnUIThread(WebPlayerView.this.progressRunnable, 1000L);
                }
            }
        };
        this.surfaceTextureListener = new TextureView.SurfaceTextureListener() {
            @Override
            public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
            }

            @Override
            public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
            }

            @Override
            public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
                if (WebPlayerView.this.changingTextureView) {
                    if (WebPlayerView.this.switchingInlineMode) {
                        WebPlayerView.this.waitingForFirstTextureUpload = 2;
                    }
                    WebPlayerView.this.textureView.setSurfaceTexture(surface);
                    WebPlayerView.this.textureView.setVisibility(0);
                    WebPlayerView.this.changingTextureView = false;
                    return false;
                }
                return true;
            }

            public class AnonymousClass1 implements ViewTreeObserver.OnPreDrawListener {
                AnonymousClass1() {
                }

                @Override
                public boolean onPreDraw() {
                    WebPlayerView.this.changedTextureView.getViewTreeObserver().removeOnPreDrawListener(this);
                    if (WebPlayerView.this.textureImageView != null) {
                        WebPlayerView.this.textureImageView.setVisibility(4);
                        WebPlayerView.this.textureImageView.setImageDrawable(null);
                        if (WebPlayerView.this.currentBitmap != null) {
                            WebPlayerView.this.currentBitmap.recycle();
                            WebPlayerView.this.currentBitmap = null;
                        }
                    }
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            WebPlayerView.AnonymousClass2.AnonymousClass1.this.lambda$onPreDraw$0$WebPlayerView$2$1();
                        }
                    });
                    WebPlayerView.this.waitingForFirstTextureUpload = 0;
                    return true;
                }

                public void lambda$onPreDraw$0$WebPlayerView$2$1() {
                    WebPlayerView.this.delegate.onInlineSurfaceTextureReady();
                }
            }

            @Override
            public void onSurfaceTextureUpdated(SurfaceTexture surface) {
                if (WebPlayerView.this.waitingForFirstTextureUpload == 1) {
                    WebPlayerView.this.changedTextureView.getViewTreeObserver().addOnPreDrawListener(new AnonymousClass1());
                    WebPlayerView.this.changedTextureView.invalidate();
                }
            }
        };
        this.switchToInlineRunnable = new Runnable() {
            @Override
            public void run() {
                WebPlayerView.this.switchingInlineMode = false;
                if (WebPlayerView.this.currentBitmap != null) {
                    WebPlayerView.this.currentBitmap.recycle();
                    WebPlayerView.this.currentBitmap = null;
                }
                WebPlayerView.this.changingTextureView = true;
                if (WebPlayerView.this.textureImageView != null) {
                    try {
                        WebPlayerView.this.currentBitmap = Bitmaps.createBitmap(WebPlayerView.this.textureView.getWidth(), WebPlayerView.this.textureView.getHeight(), Bitmap.Config.ARGB_8888);
                        WebPlayerView.this.textureView.getBitmap(WebPlayerView.this.currentBitmap);
                    } catch (Throwable e) {
                        if (WebPlayerView.this.currentBitmap != null) {
                            WebPlayerView.this.currentBitmap.recycle();
                            WebPlayerView.this.currentBitmap = null;
                        }
                        FileLog.e(e);
                    }
                    if (WebPlayerView.this.currentBitmap != null) {
                        WebPlayerView.this.textureImageView.setVisibility(0);
                        WebPlayerView.this.textureImageView.setImageBitmap(WebPlayerView.this.currentBitmap);
                    } else {
                        WebPlayerView.this.textureImageView.setImageDrawable(null);
                    }
                }
                WebPlayerView.this.isInline = true;
                WebPlayerView.this.updatePlayButton();
                WebPlayerView.this.updateShareButton();
                WebPlayerView.this.updateFullscreenButton();
                WebPlayerView.this.updateInlineButton();
                ViewGroup viewGroup = (ViewGroup) WebPlayerView.this.controlsView.getParent();
                if (viewGroup != null) {
                    viewGroup.removeView(WebPlayerView.this.controlsView);
                }
                WebPlayerView webPlayerView = WebPlayerView.this;
                webPlayerView.changedTextureView = webPlayerView.delegate.onSwitchInlineMode(WebPlayerView.this.controlsView, WebPlayerView.this.isInline, WebPlayerView.this.aspectRatioFrameLayout.getAspectRatio(), WebPlayerView.this.aspectRatioFrameLayout.getVideoRotation(), WebPlayerView.this.allowInlineAnimation);
                WebPlayerView.this.changedTextureView.setVisibility(4);
                ViewGroup parent = (ViewGroup) WebPlayerView.this.textureView.getParent();
                if (parent != null) {
                    parent.removeView(WebPlayerView.this.textureView);
                }
                WebPlayerView.this.controlsView.show(false, false);
            }
        };
        setWillNotDraw(false);
        this.delegate = webPlayerViewDelegate;
        this.backgroundPaint.setColor(-16777216);
        AspectRatioFrameLayout aspectRatioFrameLayout = new AspectRatioFrameLayout(context) {
            @Override
            public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                if (WebPlayerView.this.textureViewContainer != null) {
                    ViewGroup.LayoutParams layoutParams = WebPlayerView.this.textureView.getLayoutParams();
                    layoutParams.width = getMeasuredWidth();
                    layoutParams.height = getMeasuredHeight();
                    if (WebPlayerView.this.textureImageView != null) {
                        ViewGroup.LayoutParams layoutParams2 = WebPlayerView.this.textureImageView.getLayoutParams();
                        layoutParams2.width = getMeasuredWidth();
                        layoutParams2.height = getMeasuredHeight();
                    }
                }
            }
        };
        this.aspectRatioFrameLayout = aspectRatioFrameLayout;
        addView(aspectRatioFrameLayout, LayoutHelper.createFrame(-1, -1, 17));
        this.interfaceName = "JavaScriptInterface";
        WebView webView = new WebView(context);
        this.webView = webView;
        webView.addJavascriptInterface(new JavaScriptInterface(new CallJavaResultInterface() {
            @Override
            public final void jsCallFinished(String str) {
                WebPlayerView.this.lambda$new$0$WebPlayerView(str);
            }
        }), this.interfaceName);
        WebSettings webSettings = this.webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDefaultTextEncodingName("utf-8");
        this.textureViewContainer = this.delegate.getTextureViewContainer();
        TextureView textureView = new TextureView(context);
        this.textureView = textureView;
        textureView.setPivotX(0.0f);
        this.textureView.setPivotY(0.0f);
        ViewGroup viewGroup = this.textureViewContainer;
        if (viewGroup == null) {
            this.aspectRatioFrameLayout.addView(this.textureView, LayoutHelper.createFrame(-1, -1, 17));
        } else {
            viewGroup.addView(this.textureView);
        }
        if (this.allowInlineAnimation && this.textureViewContainer != null) {
            ImageView imageView = new ImageView(context);
            this.textureImageView = imageView;
            imageView.setBackgroundColor(SupportMenu.CATEGORY_MASK);
            this.textureImageView.setPivotX(0.0f);
            this.textureImageView.setPivotY(0.0f);
            this.textureImageView.setVisibility(4);
            this.textureViewContainer.addView(this.textureImageView);
        }
        VideoPlayer videoPlayer = new VideoPlayer();
        this.videoPlayer = videoPlayer;
        videoPlayer.setDelegate(this);
        this.videoPlayer.setTextureView(this.textureView);
        ControlsView controlsView = new ControlsView(context);
        this.controlsView = controlsView;
        ViewGroup viewGroup2 = this.textureViewContainer;
        if (viewGroup2 != null) {
            viewGroup2.addView(controlsView);
        } else {
            addView(controlsView, LayoutHelper.createFrame(-1, -1.0f));
        }
        RadialProgressView radialProgressView = new RadialProgressView(context);
        this.progressView = radialProgressView;
        radialProgressView.setProgressColor(-1);
        addView(this.progressView, LayoutHelper.createFrame(48, 48, 17));
        ImageView imageView2 = new ImageView(context);
        this.fullscreenButton = imageView2;
        imageView2.setScaleType(ImageView.ScaleType.CENTER);
        this.controlsView.addView(this.fullscreenButton, LayoutHelper.createFrame(56.0f, 56.0f, 85, 0.0f, 0.0f, 0.0f, 5.0f));
        this.fullscreenButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                WebPlayerView.this.lambda$new$1$WebPlayerView(view);
            }
        });
        ImageView imageView3 = new ImageView(context);
        this.playButton = imageView3;
        imageView3.setScaleType(ImageView.ScaleType.CENTER);
        this.controlsView.addView(this.playButton, LayoutHelper.createFrame(48, 48, 17));
        this.playButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                WebPlayerView.this.lambda$new$2$WebPlayerView(view);
            }
        });
        if (allowInline) {
            ImageView imageView4 = new ImageView(context);
            this.inlineButton = imageView4;
            imageView4.setScaleType(ImageView.ScaleType.CENTER);
            this.controlsView.addView(this.inlineButton, LayoutHelper.createFrame(56, 48, 53));
            this.inlineButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    WebPlayerView.this.lambda$new$3$WebPlayerView(view);
                }
            });
        }
        if (allowShare) {
            ImageView imageView5 = new ImageView(context);
            this.shareButton = imageView5;
            imageView5.setScaleType(ImageView.ScaleType.CENTER);
            this.shareButton.setImageResource(R.drawable.ic_share_video);
            this.controlsView.addView(this.shareButton, LayoutHelper.createFrame(56, 48, 53));
            this.shareButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    WebPlayerView.this.lambda$new$4$WebPlayerView(view);
                }
            });
        }
        updatePlayButton();
        updateFullscreenButton();
        updateInlineButton();
        updateShareButton();
    }

    public void lambda$new$0$WebPlayerView(String value) {
        AsyncTask asyncTask = this.currentTask;
        if (asyncTask != null && !asyncTask.isCancelled()) {
            AsyncTask asyncTask2 = this.currentTask;
            if (asyncTask2 instanceof YoutubeVideoTask) {
                ((YoutubeVideoTask) asyncTask2).onInterfaceResult(value);
            }
        }
    }

    public void lambda$new$1$WebPlayerView(View v) {
        if (!this.initied || this.changingTextureView || this.switchingInlineMode || !this.firstFrameRendered) {
            return;
        }
        this.inFullscreen = !this.inFullscreen;
        updateFullscreenState(true);
    }

    public void lambda$new$2$WebPlayerView(View v) {
        if (!this.initied || this.playVideoUrl == null) {
            return;
        }
        if (!this.videoPlayer.isPlayerPrepared()) {
            preparePlayer();
        }
        if (this.videoPlayer.isPlaying()) {
            this.videoPlayer.pause();
        } else {
            this.isCompleted = false;
            this.videoPlayer.play();
        }
        updatePlayButton();
    }

    public void lambda$new$3$WebPlayerView(View v) {
        if (this.textureView == null || !this.delegate.checkInlinePermissions() || this.changingTextureView || this.switchingInlineMode || !this.firstFrameRendered) {
            return;
        }
        this.switchingInlineMode = true;
        if (!this.isInline) {
            this.inFullscreen = false;
            this.delegate.prepareToSwitchInlineMode(true, this.switchToInlineRunnable, this.aspectRatioFrameLayout.getAspectRatio(), this.allowInlineAnimation);
            return;
        }
        ViewGroup parent = (ViewGroup) this.aspectRatioFrameLayout.getParent();
        if (parent != this) {
            if (parent != null) {
                parent.removeView(this.aspectRatioFrameLayout);
            }
            addView(this.aspectRatioFrameLayout, 0, LayoutHelper.createFrame(-1, -1, 17));
            this.aspectRatioFrameLayout.measure(View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() - AndroidUtilities.dp(10.0f), 1073741824));
        }
        Bitmap bitmap = this.currentBitmap;
        if (bitmap != null) {
            bitmap.recycle();
            this.currentBitmap = null;
        }
        this.changingTextureView = true;
        this.isInline = false;
        updatePlayButton();
        updateShareButton();
        updateFullscreenButton();
        updateInlineButton();
        this.textureView.setVisibility(4);
        ViewGroup viewGroup = this.textureViewContainer;
        if (viewGroup != null) {
            viewGroup.addView(this.textureView);
        } else {
            this.aspectRatioFrameLayout.addView(this.textureView);
        }
        ViewGroup parent2 = (ViewGroup) this.controlsView.getParent();
        if (parent2 != this) {
            if (parent2 != null) {
                parent2.removeView(this.controlsView);
            }
            ViewGroup viewGroup2 = this.textureViewContainer;
            if (viewGroup2 == null) {
                addView(this.controlsView, 1);
            } else {
                viewGroup2.addView(this.controlsView);
            }
        }
        this.controlsView.show(false, false);
        this.delegate.prepareToSwitchInlineMode(false, null, this.aspectRatioFrameLayout.getAspectRatio(), this.allowInlineAnimation);
    }

    public void lambda$new$4$WebPlayerView(View v) {
        WebPlayerViewDelegate webPlayerViewDelegate = this.delegate;
        if (webPlayerViewDelegate != null) {
            webPlayerViewDelegate.onSharePressed();
        }
    }

    public void onInitFailed() {
        if (this.controlsView.getParent() != this) {
            this.controlsView.setVisibility(8);
        }
        this.delegate.onInitFailed();
    }

    public void updateTextureImageView() {
        if (this.textureImageView == null) {
            return;
        }
        try {
            Bitmap createBitmap = Bitmaps.createBitmap(this.textureView.getWidth(), this.textureView.getHeight(), Bitmap.Config.ARGB_8888);
            this.currentBitmap = createBitmap;
            this.changedTextureView.getBitmap(createBitmap);
        } catch (Throwable e) {
            Bitmap bitmap = this.currentBitmap;
            if (bitmap != null) {
                bitmap.recycle();
                this.currentBitmap = null;
            }
            FileLog.e(e);
        }
        if (this.currentBitmap == null) {
            this.textureImageView.setImageDrawable(null);
        } else {
            this.textureImageView.setVisibility(0);
            this.textureImageView.setImageBitmap(this.currentBitmap);
        }
    }

    public String getYoutubeId() {
        return this.currentYoutubeId;
    }

    @Override
    public void onStateChanged(boolean playWhenReady, int playbackState) {
        if (playbackState != 2) {
            if (this.videoPlayer.getDuration() == C.TIME_UNSET) {
                this.controlsView.setDuration(0);
            } else {
                this.controlsView.setDuration((int) (this.videoPlayer.getDuration() / 1000));
            }
        }
        if (playbackState == 4 || playbackState == 1 || !this.videoPlayer.isPlaying()) {
            this.delegate.onPlayStateChanged(this, false);
        } else {
            this.delegate.onPlayStateChanged(this, true);
        }
        if (this.videoPlayer.isPlaying() && playbackState != 4) {
            updatePlayButton();
            return;
        }
        if (playbackState == 4) {
            this.isCompleted = true;
            this.videoPlayer.pause();
            this.videoPlayer.seekTo(0L);
            updatePlayButton();
            this.controlsView.show(true, true);
        }
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawRect(0.0f, 0.0f, getMeasuredWidth(), getMeasuredHeight() - AndroidUtilities.dp(10.0f), this.backgroundPaint);
    }

    @Override
    public void onError(Exception e) {
        FileLog.e(e);
        onInitFailed();
    }

    @Override
    public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
        if (this.aspectRatioFrameLayout != null) {
            if (unappliedRotationDegrees == 90 || unappliedRotationDegrees == 270) {
                width = height;
                height = width;
            }
            float ratio = height == 0 ? 1.0f : (width * pixelWidthHeightRatio) / height;
            this.aspectRatioFrameLayout.setAspectRatio(ratio, unappliedRotationDegrees);
            if (this.inFullscreen) {
                this.delegate.onVideoSizeChanged(ratio, unappliedRotationDegrees);
            }
        }
    }

    @Override
    public void onRenderedFirstFrame() {
        this.firstFrameRendered = true;
        this.lastUpdateTime = System.currentTimeMillis();
        this.controlsView.invalidate();
    }

    @Override
    public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
        if (this.changingTextureView) {
            this.changingTextureView = false;
            if (this.inFullscreen || this.isInline) {
                if (this.isInline) {
                    this.waitingForFirstTextureUpload = 1;
                }
                this.changedTextureView.setSurfaceTexture(surfaceTexture);
                this.changedTextureView.setSurfaceTextureListener(this.surfaceTextureListener);
                this.changedTextureView.setVisibility(0);
                return true;
            }
        }
        return false;
    }

    @Override
    public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
        if (this.waitingForFirstTextureUpload == 2) {
            ImageView imageView = this.textureImageView;
            if (imageView != null) {
                imageView.setVisibility(4);
                this.textureImageView.setImageDrawable(null);
                Bitmap bitmap = this.currentBitmap;
                if (bitmap != null) {
                    bitmap.recycle();
                    this.currentBitmap = null;
                }
            }
            this.switchingInlineMode = false;
            this.delegate.onSwitchInlineMode(this.controlsView, false, this.aspectRatioFrameLayout.getAspectRatio(), this.aspectRatioFrameLayout.getVideoRotation(), this.allowInlineAnimation);
            this.waitingForFirstTextureUpload = 0;
        }
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        int x = ((r - l) - this.aspectRatioFrameLayout.getMeasuredWidth()) / 2;
        int y = (((b - t) - AndroidUtilities.dp(10.0f)) - this.aspectRatioFrameLayout.getMeasuredHeight()) / 2;
        AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
        aspectRatioFrameLayout.layout(x, y, aspectRatioFrameLayout.getMeasuredWidth() + x, this.aspectRatioFrameLayout.getMeasuredHeight() + y);
        if (this.controlsView.getParent() == this) {
            ControlsView controlsView = this.controlsView;
            controlsView.layout(0, 0, controlsView.getMeasuredWidth(), this.controlsView.getMeasuredHeight());
        }
        int x2 = ((r - l) - this.progressView.getMeasuredWidth()) / 2;
        int y2 = ((b - t) - this.progressView.getMeasuredHeight()) / 2;
        RadialProgressView radialProgressView = this.progressView;
        radialProgressView.layout(x2, y2, radialProgressView.getMeasuredWidth() + x2, this.progressView.getMeasuredHeight() + y2);
        this.controlsView.imageReceiver.setImageCoords(0, 0, getMeasuredWidth(), getMeasuredHeight() - AndroidUtilities.dp(10.0f));
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = View.MeasureSpec.getSize(widthMeasureSpec);
        int height = View.MeasureSpec.getSize(heightMeasureSpec);
        this.aspectRatioFrameLayout.measure(View.MeasureSpec.makeMeasureSpec(width, 1073741824), View.MeasureSpec.makeMeasureSpec(height - AndroidUtilities.dp(10.0f), 1073741824));
        if (this.controlsView.getParent() == this) {
            this.controlsView.measure(View.MeasureSpec.makeMeasureSpec(width, 1073741824), View.MeasureSpec.makeMeasureSpec(height, 1073741824));
        }
        this.progressView.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824));
        setMeasuredDimension(width, height);
    }

    public void updatePlayButton() {
        this.controlsView.checkNeedHide();
        AndroidUtilities.cancelRunOnUIThread(this.progressRunnable);
        if (!this.videoPlayer.isPlaying()) {
            if (this.isCompleted) {
                this.playButton.setImageResource(this.isInline ? R.drawable.ic_againinline : R.drawable.ic_again);
                return;
            } else {
                this.playButton.setImageResource(this.isInline ? R.drawable.ic_playinline : R.drawable.ic_play);
                return;
            }
        }
        this.playButton.setImageResource(this.isInline ? R.drawable.ic_pauseinline : R.drawable.ic_pause);
        AndroidUtilities.runOnUIThread(this.progressRunnable, 500L);
        checkAudioFocus();
    }

    private void checkAudioFocus() {
        if (!this.hasAudioFocus) {
            AudioManager audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
            this.hasAudioFocus = true;
            if (audioManager.requestAudioFocus(this, 3, 1) == 1) {
                this.audioFocus = 2;
            }
        }
    }

    @Override
    public void onAudioFocusChange(int focusChange) {
        if (focusChange == -1) {
            if (this.videoPlayer.isPlaying()) {
                this.videoPlayer.pause();
                updatePlayButton();
            }
            this.hasAudioFocus = false;
            this.audioFocus = 0;
            return;
        }
        if (focusChange == 1) {
            this.audioFocus = 2;
            if (this.resumeAudioOnFocusGain) {
                this.resumeAudioOnFocusGain = false;
                this.videoPlayer.play();
                return;
            }
            return;
        }
        if (focusChange == -3) {
            this.audioFocus = 1;
            return;
        }
        if (focusChange == -2) {
            this.audioFocus = 0;
            if (this.videoPlayer.isPlaying()) {
                this.resumeAudioOnFocusGain = true;
                this.videoPlayer.pause();
                updatePlayButton();
            }
        }
    }

    public void updateFullscreenButton() {
        if (!this.videoPlayer.isPlayerPrepared() || this.isInline) {
            this.fullscreenButton.setVisibility(8);
            return;
        }
        this.fullscreenButton.setVisibility(0);
        if (!this.inFullscreen) {
            this.fullscreenButton.setImageResource(R.drawable.ic_gofullscreen);
            this.fullscreenButton.setLayoutParams(LayoutHelper.createFrame(56.0f, 56.0f, 85, 0.0f, 0.0f, 0.0f, 5.0f));
        } else {
            this.fullscreenButton.setImageResource(R.drawable.ic_outfullscreen);
            this.fullscreenButton.setLayoutParams(LayoutHelper.createFrame(56.0f, 56.0f, 85, 0.0f, 0.0f, 0.0f, 1.0f));
        }
    }

    public void updateShareButton() {
        ImageView imageView = this.shareButton;
        if (imageView == null) {
            return;
        }
        imageView.setVisibility((this.isInline || !this.videoPlayer.isPlayerPrepared()) ? 8 : 0);
    }

    private View getControlView() {
        return this.controlsView;
    }

    private View getProgressView() {
        return this.progressView;
    }

    public void updateInlineButton() {
        ImageView imageView = this.inlineButton;
        if (imageView == null) {
            return;
        }
        imageView.setImageResource(this.isInline ? R.drawable.ic_goinline : R.drawable.ic_outinline);
        this.inlineButton.setVisibility(this.videoPlayer.isPlayerPrepared() ? 0 : 8);
        if (this.isInline) {
            this.inlineButton.setLayoutParams(LayoutHelper.createFrame(40, 40, 53));
        } else {
            this.inlineButton.setLayoutParams(LayoutHelper.createFrame(56, 50, 53));
        }
    }

    public void preparePlayer() {
        String str = this.playVideoUrl;
        if (str == null) {
            return;
        }
        if (str != null && this.playAudioUrl != null) {
            this.videoPlayer.preparePlayerLoop(Uri.parse(str), this.playVideoType, Uri.parse(this.playAudioUrl), this.playAudioType);
        } else {
            this.videoPlayer.preparePlayer(Uri.parse(this.playVideoUrl), this.playVideoType);
        }
        this.videoPlayer.setPlayWhenReady(this.isAutoplay);
        this.isLoading = false;
        if (this.videoPlayer.getDuration() == C.TIME_UNSET) {
            this.controlsView.setDuration(0);
        } else {
            this.controlsView.setDuration((int) (this.videoPlayer.getDuration() / 1000));
        }
        updateFullscreenButton();
        updateShareButton();
        updateInlineButton();
        this.controlsView.invalidate();
        if (this.seekToTime != -1) {
            this.videoPlayer.seekTo(r0 * 1000);
        }
    }

    public void pause() {
        this.videoPlayer.pause();
        updatePlayButton();
        this.controlsView.show(true, true);
    }

    private void updateFullscreenState(boolean byButton) {
        ViewGroup parent;
        if (this.textureView == null) {
            return;
        }
        updateFullscreenButton();
        ViewGroup viewGroup = this.textureViewContainer;
        if (viewGroup == null) {
            this.changingTextureView = true;
            if (!this.inFullscreen) {
                if (viewGroup != null) {
                    viewGroup.addView(this.textureView);
                } else {
                    this.aspectRatioFrameLayout.addView(this.textureView);
                }
            }
            if (this.inFullscreen) {
                ViewGroup viewGroup2 = (ViewGroup) this.controlsView.getParent();
                if (viewGroup2 != null) {
                    viewGroup2.removeView(this.controlsView);
                }
            } else {
                ViewGroup parent2 = (ViewGroup) this.controlsView.getParent();
                if (parent2 != this) {
                    if (parent2 != null) {
                        parent2.removeView(this.controlsView);
                    }
                    ViewGroup viewGroup3 = this.textureViewContainer;
                    if (viewGroup3 == null) {
                        addView(this.controlsView, 1);
                    } else {
                        viewGroup3.addView(this.controlsView);
                    }
                }
            }
            TextureView onSwitchToFullscreen = this.delegate.onSwitchToFullscreen(this.controlsView, this.inFullscreen, this.aspectRatioFrameLayout.getAspectRatio(), this.aspectRatioFrameLayout.getVideoRotation(), byButton);
            this.changedTextureView = onSwitchToFullscreen;
            onSwitchToFullscreen.setVisibility(4);
            if (this.inFullscreen && this.changedTextureView != null && (parent = (ViewGroup) this.textureView.getParent()) != null) {
                parent.removeView(this.textureView);
            }
            this.controlsView.checkNeedHide();
            return;
        }
        if (this.inFullscreen) {
            ViewGroup viewGroup4 = (ViewGroup) this.aspectRatioFrameLayout.getParent();
            if (viewGroup4 != null) {
                viewGroup4.removeView(this.aspectRatioFrameLayout);
            }
        } else {
            ViewGroup parent3 = (ViewGroup) this.aspectRatioFrameLayout.getParent();
            if (parent3 != this) {
                if (parent3 != null) {
                    parent3.removeView(this.aspectRatioFrameLayout);
                }
                addView(this.aspectRatioFrameLayout, 0);
            }
        }
        this.delegate.onSwitchToFullscreen(this.controlsView, this.inFullscreen, this.aspectRatioFrameLayout.getAspectRatio(), this.aspectRatioFrameLayout.getVideoRotation(), byButton);
    }

    public void exitFullscreen() {
        if (!this.inFullscreen) {
            return;
        }
        this.inFullscreen = false;
        updateInlineButton();
        updateFullscreenState(false);
    }

    public boolean isInitied() {
        return this.initied;
    }

    public boolean isInline() {
        return this.isInline || this.switchingInlineMode;
    }

    public void enterFullscreen() {
        if (this.inFullscreen) {
            return;
        }
        this.inFullscreen = true;
        updateInlineButton();
        updateFullscreenState(false);
    }

    public boolean isInFullscreen() {
        return this.inFullscreen;
    }

    public String getYouTubeVideoId(String url) {
        Matcher matcher = youtubeIdRegex.matcher(url);
        if (!matcher.find()) {
            return null;
        }
        String id = matcher.group(1);
        return id;
    }

    public boolean loadVideo(String url, TLRPC.Photo thumb, Object parentObject, String originalUrl, boolean autoplay) {
        boolean z;
        String youtubeId = null;
        String vimeoId = null;
        String coubId = null;
        String twitchClipId = null;
        String twitchStreamId = null;
        String mp4File = null;
        String aparatId = null;
        this.seekToTime = -1;
        if (url != null) {
            if (url.endsWith(".mp4")) {
                mp4File = url;
            } else {
                try {
                    if (originalUrl != null) {
                        try {
                            Uri uri = Uri.parse(originalUrl);
                            String t = uri.getQueryParameter("t");
                            if (t == null) {
                                t = uri.getQueryParameter("time_continue");
                            }
                            if (t != null) {
                                if (!t.contains("m")) {
                                    this.seekToTime = Utilities.parseInt(t).intValue();
                                } else {
                                    String[] args = t.split("m");
                                    this.seekToTime = (Utilities.parseInt(args[0]).intValue() * 60) + Utilities.parseInt(args[1]).intValue();
                                }
                            }
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                    Matcher matcher = youtubeIdRegex.matcher(url);
                    String id = null;
                    if (matcher.find()) {
                        id = matcher.group(1);
                    }
                    if (id != null) {
                        youtubeId = id;
                    }
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
                if (youtubeId == null) {
                    try {
                        Matcher matcher2 = vimeoIdRegex.matcher(url);
                        String id2 = null;
                        if (matcher2.find()) {
                            id2 = matcher2.group(3);
                        }
                        if (id2 != null) {
                            vimeoId = id2;
                        }
                    } catch (Exception e3) {
                        FileLog.e(e3);
                    }
                }
                if (vimeoId == null) {
                    try {
                        Matcher matcher3 = aparatIdRegex.matcher(url);
                        String id3 = null;
                        if (matcher3.find()) {
                            id3 = matcher3.group(1);
                        }
                        if (id3 != null) {
                            aparatId = id3;
                        }
                    } catch (Exception e4) {
                        FileLog.e(e4);
                    }
                }
                if (aparatId == null) {
                    try {
                        Matcher matcher4 = twitchClipIdRegex.matcher(url);
                        String id4 = null;
                        if (matcher4.find()) {
                            id4 = matcher4.group(1);
                        }
                        if (id4 != null) {
                            twitchClipId = id4;
                        }
                    } catch (Exception e5) {
                        FileLog.e(e5);
                    }
                }
                if (twitchClipId == null) {
                    try {
                        Matcher matcher5 = twitchStreamIdRegex.matcher(url);
                        String id5 = null;
                        if (matcher5.find()) {
                            id5 = matcher5.group(1);
                        }
                        if (id5 != null) {
                            twitchStreamId = id5;
                        }
                    } catch (Exception e6) {
                        FileLog.e(e6);
                    }
                }
                if (twitchStreamId == null) {
                    try {
                        Matcher matcher6 = coubIdRegex.matcher(url);
                        String id6 = null;
                        if (matcher6.find()) {
                            id6 = matcher6.group(1);
                        }
                        if (id6 != null) {
                            coubId = id6;
                        }
                    } catch (Exception e7) {
                        FileLog.e(e7);
                    }
                }
            }
        }
        this.initied = false;
        this.isCompleted = false;
        this.isAutoplay = autoplay;
        this.playVideoUrl = null;
        this.playAudioUrl = null;
        destroy();
        this.firstFrameRendered = false;
        this.currentAlpha = 1.0f;
        AsyncTask asyncTask = this.currentTask;
        if (asyncTask != null) {
            asyncTask.cancel(true);
            this.currentTask = null;
        }
        updateFullscreenButton();
        updateShareButton();
        updateInlineButton();
        updatePlayButton();
        if (thumb != null) {
            TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(thumb.sizes, 80, true);
            if (photoSize != null) {
                this.controlsView.imageReceiver.setImage(null, null, ImageLocation.getForPhoto(photoSize, thumb), "80_80_b", 0, null, parentObject, 1);
                this.drawImage = true;
            }
        } else {
            this.drawImage = false;
        }
        AnimatorSet animatorSet = this.progressAnimation;
        if (animatorSet != null) {
            animatorSet.cancel();
            this.progressAnimation = null;
        }
        this.isLoading = true;
        this.controlsView.setProgress(0);
        if (youtubeId != null) {
            this.currentYoutubeId = youtubeId;
            youtubeId = null;
        }
        if (mp4File != null) {
            this.initied = true;
            this.playVideoUrl = mp4File;
            this.playVideoType = "other";
            if (this.isAutoplay) {
                preparePlayer();
            }
            showProgress(false, false);
            this.controlsView.show(true, true);
        } else {
            if (youtubeId != null) {
                YoutubeVideoTask task = new YoutubeVideoTask(youtubeId);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentTask = task;
                z = true;
            } else if (vimeoId != null) {
                VimeoVideoTask task2 = new VimeoVideoTask(vimeoId);
                task2.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentTask = task2;
                z = true;
            } else if (coubId != null) {
                CoubVideoTask task3 = new CoubVideoTask(coubId);
                task3.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentTask = task3;
                this.isStream = true;
                z = true;
            } else if (aparatId != null) {
                AparatVideoTask task4 = new AparatVideoTask(aparatId);
                task4.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentTask = task4;
                z = true;
            } else if (twitchClipId != null) {
                TwitchClipVideoTask task5 = new TwitchClipVideoTask(url, twitchClipId);
                task5.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentTask = task5;
                z = true;
            } else if (twitchStreamId != null) {
                TwitchStreamVideoTask task6 = new TwitchStreamVideoTask(url, twitchStreamId);
                z = true;
                task6.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentTask = task6;
                this.isStream = true;
            } else {
                z = true;
            }
            this.controlsView.show(false, false);
            showProgress(z, false);
        }
        if (youtubeId != null || vimeoId != null || coubId != null || aparatId != null || mp4File != null || twitchClipId != null || twitchStreamId != null) {
            this.controlsView.setVisibility(0);
            return true;
        }
        this.controlsView.setVisibility(8);
        return false;
    }

    public View getAspectRatioView() {
        return this.aspectRatioFrameLayout;
    }

    public TextureView getTextureView() {
        return this.textureView;
    }

    public ImageView getTextureImageView() {
        return this.textureImageView;
    }

    public View getControlsView() {
        return this.controlsView;
    }

    public void destroy() {
        this.videoPlayer.releasePlayer(false);
        AsyncTask asyncTask = this.currentTask;
        if (asyncTask != null) {
            asyncTask.cancel(true);
            this.currentTask = null;
        }
        this.webView.stopLoading();
    }

    public void showProgress(boolean show, boolean animated) {
        if (animated) {
            AnimatorSet animatorSet = this.progressAnimation;
            if (animatorSet != null) {
                animatorSet.cancel();
            }
            AnimatorSet animatorSet2 = new AnimatorSet();
            this.progressAnimation = animatorSet2;
            Animator[] animatorArr = new Animator[1];
            RadialProgressView radialProgressView = this.progressView;
            float[] fArr = new float[1];
            fArr[0] = show ? 1.0f : 0.0f;
            animatorArr[0] = ObjectAnimator.ofFloat(radialProgressView, "alpha", fArr);
            animatorSet2.playTogether(animatorArr);
            this.progressAnimation.setDuration(150L);
            this.progressAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    WebPlayerView.this.progressAnimation = null;
                }
            });
            this.progressAnimation.start();
            return;
        }
        this.progressView.setAlpha(show ? 1.0f : 0.0f);
    }
}