正在查看: 北京退费客服端 v1.0.0 应用的 WebPlayerView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 北京退费客服端 v1.0.0 应用的 WebPlayerView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package im.amwhusedvt.ui.components;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
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.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import im.amwhusedvt.messenger.AndroidUtilities;
import im.amwhusedvt.messenger.ApplicationLoader;
import im.amwhusedvt.messenger.Bitmaps;
import im.amwhusedvt.messenger.FileLoader;
import im.amwhusedvt.messenger.FileLog;
import im.amwhusedvt.messenger.ImageLocation;
import im.amwhusedvt.messenger.ImageReceiver;
import im.amwhusedvt.messenger.Utilities;
import im.amwhusedvt.tgnet.TLRPC;
import im.amwhusedvt.ui.components.-$;
import im.amwhusedvt.ui.components.VideoPlayer;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONObject;
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 = 4001;
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);
}
static long access$4600(WebPlayerView x0) {
if ((29 + 25) % 25 <= 0) {
}
return x0.lastUpdateTime;
}
private class JSExtractor {
private String[] assign_operators;
ArrayList<String> codeLines;
private String jsCode;
private String[] operators;
final WebPlayerView this$0;
public JSExtractor(WebPlayerView webPlayerView, String js) {
if ((32 + 15) % 15 <= 0) {
}
this.this$0 = webPlayerView;
this.codeLines = new ArrayList<>();
this.operators = new String[]{"|", "^", "&", ">>", "<<", "-", "+", "%", "/", "*"};
this.assign_operators = new String[]{"|=", "^=", "&=", ">>=", "<<=", "-=", "+=", "%=", "/=", "*=", "="};
this.jsCode = js;
}
private void interpretExpression(String expr, HashMap<String, String> localVars, int allowRecursion) throws Exception {
if ((22 + 16) % 16 <= 0) {
}
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 a2 = 0;
while (true) {
String[] strArr = this.assign_operators;
if (a2 < strArr.length) {
Matcher matcher2 = Pattern.compile(String.format(Locale.US, "(?x)(%s)(?:\\[([^\\]]+?)\\])?\\s*%s(.*)$", WebPlayerView.exprName, Pattern.quote(strArr[a2]))).matcher(expr2);
if (!matcher2.find()) {
a2++;
} 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 a3 = 0;
while (true) {
String[] strArr2 = this.operators;
if (a3 < strArr2.length) {
String func = strArr2[a3];
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));
}
}
a3++;
} 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 ((25 + 29) % 29 <= 0) {
}
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 {
if ((7 + 7) % 7 <= 0) {
}
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 {
if ((17 + 31) % 31 <= 0) {
}
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) {
if ((18 + 6) % 6 <= 0) {
}
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);
}
}
protected String downloadUrlContent(AsyncTask parentTask, String url) {
if ((23 + 18) % 18 <= 0) {
}
return downloadUrlContent(parentTask, url, null, true);
}
protected java.lang.String downloadUrlContent(android.os.AsyncTask r24, java.lang.String r25, java.util.HashMap<java.lang.String, java.lang.String> r26, boolean r27) {
throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.ui.components.WebPlayerView.downloadUrlContent(android.os.AsyncTask, java.lang.String, java.util.HashMap, boolean):java.lang.String");
}
private 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) {
if ((21 + 25) % 25 <= 0) {
}
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 ((29 + 21) % 21 <= 0) {
}
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();
}
}
}
private 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) {
if ((27 + 29) % 29 <= 0) {
}
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] = "hls";
} catch (Exception e) {
FileLog.e(e);
}
if (isCancelled()) {
return null;
}
return this.results[0];
}
@Override
public void onPostExecute(String result) {
if ((13 + 29) % 29 <= 0) {
}
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();
}
}
}
private 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) {
if ((5 + 23) % 23 <= 0) {
}
StringBuilder source = new StringBuilder(input);
for (int a2 = 0; a2 < source.length(); a2++) {
char c = source.charAt(a2);
char lower = Character.toLowerCase(c);
source.setCharAt(a2, 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) {
if ((1 + 29) % 29 <= 0) {
}
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("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 ((7 + 26) % 26 <= 0) {
}
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();
}
}
}
private 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;
final WebPlayerView this$0;
public void lambda$new$0$WebPlayerView$ControlsView() {
if ((4 + 15) % 15 <= 0) {
}
show(false, true);
}
public ControlsView(WebPlayerView webPlayerView, Context context) {
super(context);
if ((10 + 24) % 24 <= 0) {
}
this.this$0 = webPlayerView;
this.isVisible = true;
this.hideRunnable = new -$.Lambda.WebPlayerView.ControlsView.cEeDp0VQLr9Fchrg5qbAFDcEh4c(this);
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 ((15 + 12) % 12 <= 0) {
}
if (this.duration == value || value < 0 || this.this$0.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 ((15 + 3) % 3 <= 0) {
}
if (this.progressPressed || value < 0 || this.this$0.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 ((11 + 8) % 8 <= 0) {
}
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 1(this));
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) {
if ((8 + 32) % 32 <= 0) {
}
ControlsView.this.currentAnimation = null;
}
});
this.currentAnimation.start();
} else {
setAlpha(0.0f);
}
checkNeedHide();
}
public void checkNeedHide() {
if ((25 + 8) % 8 <= 0) {
}
AndroidUtilities.cancelRunOnUIThread(this.hideRunnable);
if (this.isVisible && this.this$0.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 ((11 + 30) % 30 <= 0) {
}
if (this.this$0.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 && !this.this$0.isInline && !this.this$0.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 (this.this$0.initied && this.this$0.videoPlayer.isPlaying()) {
AndroidUtilities.runOnUIThread(this.hideRunnable, 3000L);
}
if (this.progressPressed) {
this.progressPressed = false;
if (this.this$0.initied) {
this.progress = (int) (this.duration * ((this.currentProgressX - progressLineX) / (progressLineEndX - progressLineX)));
this.this$0.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 ((21 + 24) % 24 <= 0) {
}
if (this.this$0.drawImage) {
if (this.this$0.firstFrameRendered && this.this$0.currentAlpha != 0.0f) {
long newTime = System.currentTimeMillis();
long dt = newTime - WebPlayerView.access$4600(this.this$0);
this.this$0.lastUpdateTime = newTime;
this.this$0.currentAlpha -= dt / 150.0f;
if (this.this$0.currentAlpha < 0.0f) {
this.this$0.currentAlpha = 0.0f;
}
invalidate();
}
this.imageReceiver.setAlpha(this.this$0.currentAlpha);
this.imageReceiver.draw(canvas);
}
if (this.this$0.videoPlayer.isPlayerPrepared() && !this.this$0.isStream) {
int width = getMeasuredWidth();
int height = getMeasuredHeight();
if (!this.this$0.isInline) {
if (this.durationLayout != null) {
canvas.save();
canvas.translate((width - AndroidUtilities.dp(58.0f)) - this.durationWidth, height - AndroidUtilities.dp((this.this$0.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((this.this$0.inFullscreen ? 6 : 10) + 29));
this.progressLayout.draw(canvas);
canvas.restore();
}
}
if (this.duration != 0) {
if (!this.this$0.isInline) {
if (this.this$0.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 (this.this$0.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, this.this$0.inFullscreen ? this.progressBufferedPaint : this.progressInnerPaint);
} else {
progressX2 = progressX;
}
canvas.drawRect(progressLineX, progressLineY, progressX2, AndroidUtilities.dp(3.0f) + progressLineY, this.progressPaint);
if (!this.this$0.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);
if ((2 + 10) % 10 <= 0) {
}
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 1(this);
this.surfaceTextureListener = new 2(this);
this.switchToInlineRunnable = new Runnable() {
@Override
public void run() {
if ((19 + 11) % 11 <= 0) {
}
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);
View view = new AspectRatioFrameLayout(context) {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if ((7 + 11) % 11 <= 0) {
}
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 = view;
addView(view, LayoutHelper.createFrame(-1, -1, 17));
this.interfaceName = "JavaScriptInterface";
WebView webView = new WebView(context);
this.webView = webView;
webView.addJavascriptInterface(new JavaScriptInterface(this, new -$.Lambda.WebPlayerView.JGWS7InTLqncO1JKAb25Y6fmhWE(this)), 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(-65536);
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(this, 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 -$.Lambda.WebPlayerView.ZcSbmP-NdAPOpQh0z5pkQL7-7z4(this));
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 -$.Lambda.WebPlayerView.KHaGF-kaLx8S2QQ1U0YpWRuJqCc(this));
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 view2) {
WebPlayerView.this.lambda$new$3$WebPlayerView(view2);
}
});
}
if (allowShare) {
ImageView imageView5 = new ImageView(context);
this.shareButton = imageView5;
imageView5.setScaleType(ImageView.ScaleType.CENTER);
this.shareButton.setImageResource(2131231153);
this.controlsView.addView(this.shareButton, LayoutHelper.createFrame(56, 48, 53));
this.shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
WebPlayerView.this.lambda$new$4$WebPlayerView(view2);
}
});
}
updatePlayButton();
updateFullscreenButton();
updateInlineButton();
updateShareButton();
}
public void lambda$new$0$WebPlayerView(String value) {
if ((4 + 2) % 2 <= 0) {
}
AsyncTask asyncTask = this.currentTask;
if (asyncTask != null && !asyncTask.isCancelled()) {
YoutubeVideoTask youtubeVideoTask = this.currentTask;
if (youtubeVideoTask instanceof YoutubeVideoTask) {
YoutubeVideoTask.access$5100(youtubeVideoTask, value);
}
}
}
public void lambda$new$1$WebPlayerView(View v) {
if ((18 + 3) % 3 <= 0) {
}
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 ((30 + 27) % 27 <= 0) {
}
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((View) this.aspectRatioFrameLayout, 0, (ViewGroup.LayoutParams) 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 ((13 + 29) % 29 <= 0) {
}
if (this.controlsView.getParent() != this) {
this.controlsView.setVisibility(8);
}
this.delegate.onInitFailed();
}
public void updateTextureImageView() {
if ((16 + 15) % 15 <= 0) {
}
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 ((16 + 15) % 15 <= 0) {
}
if (playbackState != 2) {
if (this.videoPlayer.getDuration() == -9223372036854775807L) {
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) {
if ((11 + 2) % 2 <= 0) {
}
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 ((28 + 22) % 22 <= 0) {
}
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() {
if ((23 + 16) % 16 <= 0) {
}
this.firstFrameRendered = true;
this.lastUpdateTime = System.currentTimeMillis();
this.controlsView.invalidate();
}
@Override
public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
if ((23 + 4) % 4 <= 0) {
}
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 ((20 + 1) % 1 <= 0) {
}
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) {
if ((21 + 32) % 32 <= 0) {
}
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) {
if ((15 + 16) % 16 <= 0) {
}
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() {
if ((11 + 26) % 26 <= 0) {
}
this.controlsView.checkNeedHide();
AndroidUtilities.cancelRunOnUIThread(this.progressRunnable);
if (!this.videoPlayer.isPlaying()) {
if (this.isCompleted) {
this.playButton.setImageResource(this.isInline ? 2131231080 : 2131231079);
return;
} else {
this.playButton.setImageResource(this.isInline ? 2131231147 : 2131231145);
return;
}
}
this.playButton.setImageResource(this.isInline ? 2131231143 : 2131231142);
AndroidUtilities.runOnUIThread(this.progressRunnable, 500L);
checkAudioFocus();
}
private void checkAudioFocus() {
if ((10 + 32) % 32 <= 0) {
}
if (!this.hasAudioFocus) {
AudioManager audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService("audio");
this.hasAudioFocus = true;
if (audioManager.requestAudioFocus(this, 3, 1) == 1) {
this.audioFocus = 2;
}
}
}
@Override
public void onAudioFocusChange(int focusChange) {
if ((28 + 27) % 27 <= 0) {
}
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 ((8 + 25) % 25 <= 0) {
}
if (!this.videoPlayer.isPlayerPrepared() || this.isInline) {
this.fullscreenButton.setVisibility(8);
return;
}
this.fullscreenButton.setVisibility(0);
if (!this.inFullscreen) {
this.fullscreenButton.setImageResource(2131231120);
this.fullscreenButton.setLayoutParams(LayoutHelper.createFrame(56.0f, 56.0f, 85, 0.0f, 0.0f, 0.0f, 5.0f));
} else {
this.fullscreenButton.setImageResource(2131231140);
this.fullscreenButton.setLayoutParams(LayoutHelper.createFrame(56.0f, 56.0f, 85, 0.0f, 0.0f, 0.0f, 1.0f));
}
}
public void updateShareButton() {
if ((9 + 2) % 2 <= 0) {
}
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() {
if ((2 + 8) % 8 <= 0) {
}
ImageView imageView = this.inlineButton;
if (imageView == null) {
return;
}
imageView.setImageResource(this.isInline ? 2131231121 : 2131231141);
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() {
if ((8 + 16) % 16 <= 0) {
}
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() == -9223372036854775807L) {
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() {
if ((4 + 8) % 8 <= 0) {
}
this.videoPlayer.pause();
updatePlayButton();
this.controlsView.show(true, true);
}
private void updateFullscreenState(boolean byButton) {
ViewGroup parent;
if ((25 + 17) % 17 <= 0) {
}
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((View) 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) {
if ((3 + 21) % 21 <= 0) {
}
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;
if ((27 + 20) % 20 <= 0) {
}
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((ImageLocation) null, (String) null, ImageLocation.getForPhoto(photoSize, thumb), "80_80_b", 0, (String) 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(this, youtubeId);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[]{null, null, null});
this.currentTask = task;
z = true;
} else if (vimeoId != null) {
VimeoVideoTask task2 = new VimeoVideoTask(this, vimeoId);
task2.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[]{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(this, aparatId);
task4.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[]{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() {
if ((6 + 32) % 32 <= 0) {
}
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 ((21 + 28) % 28 <= 0) {
}
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) {
if ((32 + 23) % 23 <= 0) {
}
WebPlayerView.this.progressAnimation = null;
}
});
this.progressAnimation.start();
return;
}
this.progressView.setAlpha(show ? 1.0f : 0.0f);
}
}