FLIX VISION v2.8.2版本的 MD5 值为:4d33b143293b36f23ce5a6a5834e6993
以下内容为反编译后的 SimpleVideoPlayer.java 源代码,内容仅作参考
package flix.com.vision.activities.player;
import aa.g;
import aa.h;
import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextClock;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.d;
import androidx.mediarouter.app.MediaRouteButton;
import com.github.ybq.android.spinkit.SpinKitView;
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaLoadRequestData;
import com.google.android.gms.cast.MediaMetadata;
import com.google.android.gms.cast.framework.CastButtonFactory;
import com.google.android.gms.cast.framework.CastContext;
import com.google.android.gms.cast.framework.CastSession;
import com.google.android.gms.cast.framework.SessionManager;
import com.google.android.gms.cast.framework.SessionManagerListener;
import com.google.android.gms.cast.framework.media.RemoteMediaClient;
import com.google.android.gms.common.images.WebImage;
import com.squareup.picasso.Picasso;
import com.unity3d.ads.IUnityAdsInitializationListener;
import com.unity3d.ads.IUnityAdsShowListener;
import com.unity3d.ads.UnityAds;
import d.j;
import flix.com.vision.App;
import flix.com.vision.R;
import flix.com.vision.api.realdebrid.RealDebridCommon;
import flix.com.vision.bvp.BetterVideoPlayer;
import flix.com.vision.bvp.subtitle.CaptionsView;
import flix.com.vision.cast.ExpandedControlsActivity;
import flix.com.vision.exomedia.core.video.scale.ScaleType;
import flix.com.vision.helpers.Constants;
import flix.com.vision.models.Movie;
import flix.com.vision.subtitles.SubtitlesWebViewActivity;
import flix.com.vision.tv.Constant;
import hb.e;
import hb.f;
import ib.l;
import ib.m;
import ib.n;
import ib.o;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Objects;
import org.apache.commons.lang3.time.DateUtils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import v9.v;
import v9.x;
import v9.y;
import v9.z;
public class SimpleVideoPlayer extends j implements ga.b, e, f, IUnityAdsInitializationListener {
public static final int C0 = 0;
public int B0;
public TextClock E;
public MediaRouteButton F;
public ImageView G;
public Handler H;
public aa.e I;
public SpinKitView K;
public Typeface L;
public p2.a M;
public String N;
public Menu O;
public View P;
public BetterVideoPlayer Q;
public TextView T;
public TextView U;
public TextView V;
public TextView W;
public Movie X;
public ImageView Y;
public ImageView Z;
public LinearLayout f11977a0;
public LinearLayout f11978b0;
public CastContext f11979c0;
public String f11983g0;
public String f11985i0;
public int f11986j0;
public int f11987k0;
public aa.e f11988l0;
public Animation f11995s0;
public Animation f11996t0;
public String f11997u0;
public CastSession f12000x0;
public SessionManager f12001y0;
public boolean D = true;
public ArrayList<o> J = new ArrayList<>();
public final gb.b R = new gb.b();
public Handler S = new Handler();
public int f11980d0 = 0;
public String f11981e0 = null;
public boolean f11982f0 = true;
public boolean f11984h0 = false;
public boolean f11989m0 = false;
public int f11990n0 = 0;
public boolean f11991o0 = false;
public int f11992p0 = -1;
public int f11993q0 = -1;
public boolean f11994r0 = false;
public boolean f11998v0 = false;
public la.d f11999w0 = null;
public final d f12002z0 = new d();
public ArrayList<m> A0 = new ArrayList<>();
public class a implements ra.a {
public a() {
}
@Override
public void onError(qa.a aVar, Exception exc) {
}
@Override
public void onSeekComplete() {
}
@Override
public void onStateChanged(boolean z10, int i10) {
SimpleVideoPlayer simpleVideoPlayer = SimpleVideoPlayer.this;
if (i10 == 2) {
simpleVideoPlayer.K.setVisibility(0);
if (simpleVideoPlayer.f11982f0) {
try {
simpleVideoPlayer.H.removeCallbacks(simpleVideoPlayer.I);
} catch (Exception unused) {
}
}
} else {
simpleVideoPlayer.K.setVisibility(8);
simpleVideoPlayer.Q.hideToolbar();
}
Movie movie = simpleVideoPlayer.X;
if (movie != null && simpleVideoPlayer.f11982f0 && z10 && i10 != 4 && movie.isSeries()) {
simpleVideoPlayer.h();
}
}
@Override
public void onVideoSizeChanged(int i10, int i11, int i12, float f10) {
}
}
public class b extends RemoteMediaClient.Callback {
public final RemoteMediaClient f12004a;
public b(RemoteMediaClient remoteMediaClient) {
this.f12004a = remoteMediaClient;
}
@Override
public void onStatusUpdated() {
SimpleVideoPlayer simpleVideoPlayer = SimpleVideoPlayer.this;
simpleVideoPlayer.startActivity(new Intent(simpleVideoPlayer, (Class<?>) ExpandedControlsActivity.class));
this.f12004a.unregisterCallback(this);
}
}
public class c implements IUnityAdsShowListener {
@Override
public void onUnityAdsShowClick(String str) {
Log.v("UnityAdsExample", "onUnityAdsShowClick: " + str);
}
@Override
public void onUnityAdsShowComplete(String str, UnityAds.UnityAdsShowCompletionState unityAdsShowCompletionState) {
Log.v("UnityAdsExample", "onUnityAdsShowComplete: " + str);
}
@Override
public void onUnityAdsShowFailure(String str, UnityAds.UnityAdsShowError unityAdsShowError, String str2) {
Log.e("UnityAdsExample", "Unity Ads failed to show ad for " + str + " with error: [" + unityAdsShowError + "] " + str2);
}
@Override
public void onUnityAdsShowStart(String str) {
Log.v("UnityAdsExample", "onUnityAdsShowStart: " + str);
}
}
public class d implements SessionManagerListener<CastSession> {
public d() {
}
@Override
public void onSessionEnded(CastSession castSession, int i10) {
}
@Override
public void onSessionEnding(CastSession castSession) {
}
@Override
public void onSessionResumeFailed(CastSession castSession, int i10) {
}
@Override
public void onSessionResumed(CastSession castSession, boolean z10) {
SimpleVideoPlayer simpleVideoPlayer = SimpleVideoPlayer.this;
BetterVideoPlayer betterVideoPlayer = simpleVideoPlayer.Q;
if (betterVideoPlayer != null) {
betterVideoPlayer.getToolbar().invalidateMenu();
}
simpleVideoPlayer.f12000x0 = castSession;
}
@Override
public void onSessionResuming(CastSession castSession, String str) {
}
@Override
public void onSessionStartFailed(CastSession castSession, int i10) {
CastContext castContext = SimpleVideoPlayer.this.f11979c0;
if (castContext != null) {
castContext.getCastReasonCodeForCastStatusCode(i10);
}
}
@Override
public void onSessionStarted(CastSession castSession, String str) {
SimpleVideoPlayer simpleVideoPlayer = SimpleVideoPlayer.this;
simpleVideoPlayer.Q.getToolbar().invalidateMenu();
simpleVideoPlayer.f12000x0 = castSession;
simpleVideoPlayer.e(simpleVideoPlayer.Q.getSource().toString());
}
@Override
public void onSessionStarting(CastSession castSession) {
}
@Override
public void onSessionSuspended(CastSession castSession, int i10) {
}
}
public SimpleVideoPlayer() {
new c();
this.B0 = -1;
}
public static void d(SimpleVideoPlayer simpleVideoPlayer) {
simpleVideoPlayer.getClass();
try {
if (simpleVideoPlayer.f11981e0 != null) {
App.getInstance().f11732q.edit().putInt(simpleVideoPlayer.f11981e0, simpleVideoPlayer.Q.getCurrentPosition()).apply();
}
simpleVideoPlayer.Q.stop();
simpleVideoPlayer.Q.release();
super.onBackPressed();
simpleVideoPlayer.finish();
} catch (Exception unused) {
}
}
@Override
public void OnM3USuccess(ArrayList<o> arrayList) {
this.J.addAll(arrayList);
}
@Override
public void OnSuccess(o oVar) {
int i10 = 1;
if (oVar.f13829l) {
if (oVar.f13833p || App.isRdSupported(oVar.f13838u)) {
ca.a.getLinkRealDebrid(oVar.f13838u, RealDebridCommon.f12032h, RealDebridCommon.f12030b).observeOn(oc.a.mainThread()).subscribeOn(fd.a.newThread()).subscribe(new g(this), new v(i10, oVar));
return;
}
return;
}
if (oVar.f13834q) {
la.d dVar = this.f11999w0;
if (dVar != null) {
try {
dVar.dismiss();
} catch (Exception unused) {
}
}
this.J.add(oVar);
if (this.f11998v0 && this.Q.isPrepared()) {
return;
}
this.f11998v0 = true;
this.T.setText(this.T.getText().toString().replace("S" + this.f11986j0 + "E" + this.f11987k0, "S" + this.f11986j0 + "E" + (this.f11987k0 + 1)));
this.f11987k0 = this.f11987k0 + 1;
this.U.setText("Episode " + this.f11987k0);
playLink(oVar.f13838u);
try {
ja.a.Success(getApplicationContext(), "Episode " + this.f11987k0 + " Loaded", null, 48, 0);
} catch (Exception unused2) {
}
this.f11981e0 = this.X.getMovieId() + "" + this.f11986j0 + "" + this.f11987k0;
return;
}
la.d dVar2 = this.f11999w0;
if (dVar2 != null) {
try {
dVar2.dismiss();
} catch (Exception unused3) {
}
}
String str = this.f11997u0;
if (str == null || !Objects.equals(oVar.f13830m, str)) {
return;
}
this.T.setText(this.T.getText().toString().replace("S" + this.f11986j0 + "E" + this.f11987k0, "S" + this.f11986j0 + "E" + (this.f11987k0 + 1)));
this.f11987k0 = this.f11987k0 + 1;
this.U.setText("Episode " + this.f11987k0);
playLink(oVar.f13838u);
try {
ja.a.Success(getApplicationContext(), "Episode " + this.f11987k0 + " Loaded", null, 48, 0);
} catch (Exception unused4) {
}
this.f11981e0 = this.X.getMovieId() + "" + this.f11986j0 + "" + this.f11987k0;
new qb.b(this, this).process(oVar);
}
@Override
public void OnSuccess(ArrayList<o> arrayList) {
}
public final void e(String str) {
RemoteMediaClient remoteMediaClient;
CastSession castSession = this.f12000x0;
if (castSession == null || (remoteMediaClient = castSession.getRemoteMediaClient()) == null) {
return;
}
remoteMediaClient.registerCallback(new b(remoteMediaClient));
Movie movie = this.X;
String image_url = movie != null ? movie.getImage_url() : null;
MediaMetadata mediaMetadata = new MediaMetadata(1);
mediaMetadata.putString("com.google.android.gms.cast.metadata.TITLE", this.T.getText().toString());
mediaMetadata.putString("com.google.android.gms.cast.metadata.SUBTITLE", this.V.getText().toString());
String str2 = !str.contains("hls") ? "video/*" : "application/vnd.apple.mpegurl";
String str3 = this.f11983g0;
if (str3 != null && str3.length() > 5) {
str2 = this.f11983g0;
}
if (image_url != null && image_url.length() > 1) {
mediaMetadata.addImage(new WebImage(Uri.parse(image_url)));
}
MediaLoadRequestData.Builder mediaInfo = new MediaLoadRequestData.Builder().setMediaInfo(new MediaInfo.Builder(str).setStreamType(1).setContentType(str2).setMetadata(mediaMetadata).setStreamDuration(this.Q.getDuration() * 1000).build());
BetterVideoPlayer betterVideoPlayer = this.Q;
remoteMediaClient.load(mediaInfo.setCurrentTime((betterVideoPlayer == null || !betterVideoPlayer.isPrepared()) ? 0L : this.Q.getCurrentPosition()).build());
finish();
}
public final void f() {
if (this.Q.isPrepared() && this.Q.isPlaying()) {
this.Q.pause();
this.Z.setVisibility(0);
this.Q.pause();
this.Q.getToolbar().getMenu().getItem(1).setIcon(R.drawable.ic_play_circle2);
}
try {
if (y.a.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == -1) {
x.a.requestPermissions(this, new String[]{"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"}, 10001);
Toast.makeText(getBaseContext(), "Grant Storage permission First", 0).show();
return;
}
} catch (Exception e10) {
e10.printStackTrace();
}
Intent intent = new Intent(this, (Class<?>) SubtitlesWebViewActivity.class);
StringBuilder s10 = a.b.s("https://www.opensubtitles.org/en/search/sublanguageid-", App.getInstance().f11732q.getString("sub_lang_code_1", "eng"), "/imdbid-");
s10.append(this.X.getImdbID().replace("tt", ""));
String sb2 = s10.toString();
if (this.X.isSeries() && App.getInstance().f11721b != null) {
sb2 = App.getInstance().f11721b;
}
intent.putExtra("url", sb2);
String title = this.X.getTitle();
if (this.X.isSeries()) {
StringBuilder r10 = a.b.r(title, " - S");
r10.append(cc.f.formatSeasonnumber(this.f11986j0));
r10.append("E");
r10.append(cc.f.formatSeasonnumber(this.f11987k0));
title = r10.toString();
}
intent.putExtra("title", title);
startActivity(intent);
}
public final void g() {
if (this.f11978b0.getVisibility() == 8) {
return;
}
this.f11978b0.animate().cancel();
this.f11978b0.startAnimation(this.f11996t0);
this.f11978b0.setVisibility(8);
}
public final void h() {
long j10;
int i10 = App.getInstance().f11732q.getInt("pref_auto_play_minutes", 2);
if (i10 != 0) {
if (i10 != 1) {
if (i10 == 2) {
j10 = 180000;
} else if (i10 == 3) {
j10 = 240000;
} else if (i10 == 4) {
j10 = 300000;
} else if (i10 == 5) {
j10 = 360000;
}
}
j10 = 120000;
} else {
j10 = 60000;
}
long duration = ((!this.Q.isPrepared() || this.Q.getDuration() - this.Q.getCurrentPosition() <= 120000) ? -1L : this.Q.getDuration() - this.Q.getCurrentPosition()) - j10;
if (duration < 1000) {
this.H.removeCallbacks(this.I);
return;
}
long j11 = duration / DateUtils.MILLIS_PER_MINUTE;
this.H.removeCallbacks(this.I);
this.H.postDelayed(this.I, duration);
}
public final void i() {
FragmentManager fragmentManager = getFragmentManager();
la.d newInstance = la.d.newInstance(this, true);
newInstance.setTitle("Error Downloading Subtitles");
newInstance.setMessage("Would you like to Download directly from OpenSubtitles Website ?");
newInstance.setButton2("CANCEL", new y(18));
newInstance.setButton1("YES, DOWNLOAD", new aa.f(this, 2));
try {
newInstance.show(fragmentManager, "");
} catch (Exception e10) {
e10.printStackTrace();
}
}
public final void j() {
ArrayList<m> arrayList;
if (!this.Q.isCaptionActive() && (arrayList = this.A0) != null && !arrayList.isEmpty()) {
k();
return;
}
if (this.X.isAnime()) {
return;
}
FragmentManager fragmentManager = getFragmentManager();
la.d newInstance = la.d.newInstance(this, true);
newInstance.setTitle(App.getInstance().f11732q.getString("sub_lang_name_1", "English") + " Subtitles");
newInstance.setMessage("You can Download Subtitles from OpenSubtitles");
if (this.Q.isCaptionActive()) {
newInstance.setMessage("Disable, Change Subtitles or Adjust Offset");
newInstance.setButton1("DISABLE", new aa.f(this, 7));
newInstance.setButton3("OFFSET", new aa.f(this, 8));
} else {
newInstance.setButton3("IMPORT", new aa.f(this, 9));
Movie movie = this.X;
String str = null;
if (movie != null && !movie.isSeries()) {
str = App.getInstance().f11732q.getString(this.X.getMovieId() + "subtitle", null);
} else if (this.X != null) {
String str2 = this.X.getMovieId() + "" + this.f11986j0 + "" + this.f11987k0;
str = App.getInstance().f11732q.getString(str2 + "subtitle", null);
}
if (str == null || !new File(str).exists()) {
newInstance.setButton1("CANCEL", new y(19));
} else {
newInstance.setButton1("ENABLE", new z(4, this, str));
}
}
ArrayList<m> arrayList2 = this.A0;
newInstance.setButton2((arrayList2 == null || arrayList2.isEmpty()) ? "DOWNLOAD" : "SHOW LIST", new aa.f(this, 10));
try {
newInstance.show(fragmentManager, "");
} catch (Exception e10) {
e10.printStackTrace();
}
}
public final void k() {
if (this.A0.isEmpty()) {
cc.d.makeToast(this, "No Subtitle Found", false);
return;
}
try {
ArrayList arrayList = new ArrayList();
for (int i10 = 0; i10 < this.A0.size(); i10++) {
arrayList.add(this.A0.get(i10).f13821g.toUpperCase(Locale.ROOT));
}
CharSequence[] charSequenceArr = (CharSequence[]) arrayList.toArray(new CharSequence[arrayList.size()]);
d.a aVar = new d.a(new ContextThemeWrapper(this, R.style.AlertDialogNoHeader));
aVar.setSingleChoiceItems(charSequenceArr, this.B0, new v9.m(this, 3));
aVar.setOnDismissListener(new x(9));
aVar.show();
} catch (Exception unused) {
}
}
public final void l(int i10) {
try {
this.Q.setSubSize(i10 == 2 ? getResources().getDimensionPixelSize(R.dimen.sub_size_normal) : i10 == 1 ? getResources().getDimensionPixelSize(R.dimen.sub_size_small) : i10 == 3 ? getResources().getDimensionPixelSize(R.dimen.sub_size_big) : i10 == 4 ? getResources().getDimensionPixelSize(R.dimen.sub_size_big_big) : i10 == 5 ? getResources().getDimensionPixelSize(R.dimen.sub_size_big_big_big) : i10 == 6 ? getResources().getDimensionPixelSize(R.dimen.sub_size_big_big_big_big) : i10 == 7 ? getResources().getDimensionPixelSize(R.dimen.sub_size_big_big_big_big_big) : getResources().getDimensionPixelSize(R.dimen.sub_size_normal));
} catch (Exception e10) {
e10.printStackTrace();
}
}
@Override
public void onActivityResult(int i10, int i11, Intent intent) {
if (i10 == 12345 && i11 == -1) {
String stringExtra = intent.getStringExtra("fileExtraPath");
if (!stringExtra.endsWith(".srt") && !stringExtra.endsWith(".vtt")) {
Toast.makeText(getBaseContext(), getString(R.string.srt_vtt_only_sub), 0).show();
return;
} else {
try {
ja.a.Success(getApplicationContext(), "Subtitles Loaded", null, 48, 0);
} catch (Exception unused) {
}
this.Q.setCaptionsPath(stringExtra, CaptionsView.CMime.SUBRIP, "");
}
}
super.onActivityResult(i10, i11, intent);
}
@Override
public void onBackPressed() {
super.onBackPressed();
if (this.Q.isControlsShown()) {
this.Q.hideControls();
} else {
showDialog();
}
}
@Override
public void onBuffering(int i10) {
}
@Override
public void onCompletion(BetterVideoPlayer betterVideoPlayer) {
}
@Override
public void onCreate(Bundle bundle) {
String str;
super.onCreate(bundle);
App.getInstance().f11732q.getBoolean("IS_RD_LOGGED_IN", false);
int i10 = 1;
this.D = App.getInstance().f11732q.getBoolean("pref_show_time", true);
EventBus.getDefault().register(this);
this.f11995s0 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
this.f11996t0 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down);
if (App.getInstance().f11732q.getBoolean("show_unity_ads", false)) {
Context applicationContext = getApplicationContext();
String str2 = Constants.f12301a;
UnityAds.initialize(applicationContext, "5218941", true, this);
}
boolean z10 = App.getInstance().f11732q.getBoolean("pref_auto_play_next_ep", false) && !App.getInstance().f11732q.getBoolean("IS_RD_LOGGED_IN", false);
this.f11982f0 = z10;
if (z10) {
this.H = new Handler();
this.I = new aa.e(this, i10);
}
setContentView(App.D ? R.layout.activity_player : R.layout.activity_player_light);
ArrayList<o> parcelableArrayListExtra = getIntent().getParcelableArrayListExtra("sources");
this.J = parcelableArrayListExtra;
if (parcelableArrayListExtra == null) {
this.J = new ArrayList<>();
}
this.f11992p0 = getIntent().getIntExtra("current_index", -1);
AssetManager assets = getAssets();
String str3 = Constant.f12431b;
Typeface.createFromAsset(assets, "fonts/pproduct_sans_rregular.ttf");
this.L = Typeface.createFromAsset(getAssets(), "fonts/product_sans_bold.ttf");
this.M = new p2.a();
this.X = (Movie) getIntent().getSerializableExtra("movie");
this.f11980d0 = getIntent().getIntExtra("runtime", 0);
this.f11986j0 = getIntent().getIntExtra("season_number", 0);
this.f11987k0 = getIntent().getIntExtra("episode_number", 0);
getIntent().getIntExtra("episode_count", 0);
this.f11997u0 = getIntent().getStringExtra("language");
this.Q = (BetterVideoPlayer) findViewById(R.id.player);
int i11 = 3;
l(App.getInstance().f11732q.getInt("pref_subtitle_size", 3));
this.Q.setSubColor(App.getInstance().f11732q.getInt("subtitle_color_res48", R.color.md_white_1));
if (App.D) {
this.Q.setEnableClick(false);
}
this.Q.f12071w.getProgressDrawable().setColorFilter(getResources().getColor(R.color.accent), PorterDuff.Mode.MULTIPLY);
int i12 = 5;
this.Q.f12071w.setOnFocusChangeListener(new i6.b(this, i12));
this.K = (SpinKitView) findViewById(R.id.buffering_view);
this.Q.setOnExoErrorListener(new g(this));
this.Q.setOnExoBufferingUpdate(new a());
this.W = (TextView) findViewById(R.id.text_view_rating);
this.Q.getToolbar().inflateMenu(App.D ? R.menu.menu_simple_video_player : R.menu.menu_simple_video_player_cast);
if (!App.D) {
try {
CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), this.Q.getToolbar().getMenu(), R.id.media_route_menu_item);
} catch (Exception unused) {
}
new Handler().postDelayed(new aa.e(this, 2), 1000L);
} else if (!this.X.isAnime()) {
new Handler().postDelayed(new aa.e(this, i12), 300L);
}
this.Q.getToolbar().setOnMenuItemClickListener(new g(this));
this.G = (ImageView) findViewById(R.id.next_episode_button);
MediaRouteButton mediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
this.F = mediaRouteButton;
if (mediaRouteButton != null && !App.D) {
CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), this.F);
CastContext sharedInstance = CastContext.getSharedInstance(this);
this.f11979c0 = sharedInstance;
this.f12001y0 = sharedInstance.getSessionManager();
}
this.E = (TextClock) findViewById(R.id.clock);
this.Z = (ImageView) findViewById(R.id.pause_icon);
this.f11977a0 = (LinearLayout) findViewById(R.id.movie_title_container);
this.f11978b0 = (LinearLayout) findViewById(R.id.next_episode_layout);
this.T = (TextView) findViewById(R.id.movie_title_player_text);
this.Y = (ImageView) findViewById(R.id.poster_image);
this.U = (TextView) findViewById(R.id.undertitle_episode);
this.V = (TextView) findViewById(R.id.undertitle);
this.Q.setAutoPlay(true);
this.Q.setBottomProgressBarVisibility(false);
this.Q.setHideControlsOnPlay(true);
this.Q.setHideControlsDuration(5000);
this.Q.setCallback(this);
this.Q.enableSwipeGestures(getWindow());
this.S = new Handler();
this.f11988l0 = new aa.e(this, 6);
this.O = this.Q.getToolbar().getMenu();
this.Q.getVideoView().setScaleType(ScaleType.NONE);
View decorView = getWindow().getDecorView();
this.P = decorView;
decorView.setSystemUiVisibility(1028);
String stringExtra = getIntent().getStringExtra("movie_id");
this.f11981e0 = stringExtra;
if (stringExtra != null) {
this.f11990n0 = App.getInstance().f11732q.getInt(this.f11981e0, -1);
}
String stringExtra2 = getIntent().getStringExtra("movie_rating");
if (stringExtra2 != null) {
this.W.setText(stringExtra2);
this.W.setVisibility(0);
}
Movie movie = this.X;
if (movie != null) {
try {
String image_url = movie.getImage_url();
if (image_url != null && !image_url.isEmpty()) {
try {
Picasso.get().load(image_url).fit().centerCrop().into(this.Y, new h(this));
} catch (Exception e10) {
e10.printStackTrace();
}
}
String stringExtra3 = getIntent().getStringExtra("title");
if (stringExtra3 != null) {
this.T.setText(stringExtra3);
}
int i13 = this.f11980d0;
if (i13 > 0) {
if (i13 > 60) {
str = (this.f11980d0 / 60) + "h " + (this.f11980d0 % 60) + "m";
} else {
str = this.f11980d0 + "m";
}
this.V.setText(this.X.getYear() + " · " + str);
} else {
this.V.setText(this.X.getYear());
}
if (this.X.isSeries() || this.X.isAnime()) {
String stringExtra4 = getIntent().getStringExtra("title_episode");
this.f11985i0 = stringExtra4;
if (stringExtra4 != null && !stringExtra4.isEmpty()) {
this.U.setVisibility(0);
this.U.setText(this.f11985i0);
}
}
} catch (Exception unused2) {
}
}
this.M.applyFontToView(this.T, this.L);
Movie movie2 = this.X;
if (movie2 != null && this.G != null && movie2.isSeries() && this.f11982f0) {
this.G.setOnClickListener(new aa.f(this, i10));
}
this.N = getIntent().getStringExtra("streamUrl");
this.f11983g0 = getIntent().getStringExtra("mimeType");
String stringExtra5 = getIntent().getStringExtra("referer");
if (cc.f.notNull(stringExtra5)) {
HashMap hashMap = App.A;
hashMap.clear();
hashMap.put("Referer", stringExtra5);
}
if (!App.D) {
new Handler().postDelayed(new aa.e(this, i11), 1500L);
return;
}
String str4 = this.N;
if (str4 != null) {
playLink(str4);
}
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onError(BetterVideoPlayer betterVideoPlayer) {
}
@Override
public void onInitializationComplete() {
}
@Override
public void onInitializationFailed(UnityAds.UnityAdsInitializationError unityAdsInitializationError, String str) {
}
@Override
public boolean onKeyDown(int i10, KeyEvent keyEvent) {
int directionPressed = this.R.getDirectionPressed(keyEvent);
if (!this.Q.isControlsShown()) {
if (directionPressed == 1 || directionPressed == 7) {
if (!this.Q.isPlaying() || !this.Q.isPrepared()) {
return false;
}
try {
this.Q.seekTo(this.Q.getCurrentPosition() - 15000);
this.Q.showOverlayText(15, false);
} catch (Exception e10) {
e10.printStackTrace();
}
return true;
}
if (directionPressed == 2 || directionPressed == 6) {
if (!this.Q.isPlaying() || !this.Q.isPrepared()) {
return false;
}
try {
this.Q.seekTo(this.Q.getCurrentPosition() + 15000);
this.Q.showOverlayText(15, true);
} catch (Exception e11) {
e11.printStackTrace();
}
return true;
}
if (directionPressed == 4) {
try {
if (this.Q.isPlaying()) {
this.Q.pause();
this.Z.setVisibility(0);
this.Q.getToolbar().getMenu().getItem(1).setIcon(R.drawable.ic_play_circle2);
} else if (this.Q.isPrepared()) {
this.Z.setVisibility(8);
this.Q.start();
this.Q.getToolbar().getMenu().getItem(1).setIcon(R.drawable.ic_pause_cirlce);
}
} catch (Exception e12) {
e12.printStackTrace();
}
return true;
}
}
this.Q.showControls();
if (directionPressed == 4) {
this.Q.toggleControls();
return true;
}
if (directionPressed != 5) {
switch (directionPressed) {
case 8:
case 9:
break;
case 10:
if (this.Q.isControlsShown()) {
this.Q.hideControls();
return true;
}
showDialog();
return true;
case 11:
return true;
default:
return false;
}
}
try {
if (this.Q.isPlaying()) {
this.Z.setVisibility(0);
this.Q.pause();
this.Q.getToolbar().getMenu().getItem(1).setIcon(R.drawable.ic_play_circle2);
if (this.f11981e0 != null) {
App.getInstance().f11732q.edit().putInt(this.f11981e0, this.Q.getCurrentPosition()).apply();
}
requestAndDisplayAd();
} else if (this.Q.isPrepared()) {
this.Z.setVisibility(8);
this.f11991o0 = false;
this.Q.getToolbar().getMenu().getItem(1).setIcon(R.drawable.ic_pause_cirlce);
this.Q.start();
}
this.Q.showControls();
} catch (Exception e13) {
e13.printStackTrace();
}
return true;
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent() {
if (this.Q.isControlsShown()) {
this.Q.hideControls();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(ib.c cVar) {
String str;
if (cVar == null || (str = cVar.f13768a) == null) {
if (cVar == null || cVar.f13768a != null) {
return;
}
i();
return;
}
try {
if (str.endsWith(".srt") || cVar.f13768a.endsWith(".vtt")) {
BetterVideoPlayer betterVideoPlayer = this.Q;
String str2 = cVar.f13768a;
betterVideoPlayer.setCaptionsPath(str2, str2.contains(".srt") ? CaptionsView.CMime.SUBRIP : CaptionsView.CMime.WEBVTT, "");
this.Q.start();
this.Z.setVisibility(8);
this.Q.getToolbar().getMenu().getItem(1).setIcon(R.drawable.ic_pause_cirlce);
this.Q.hideControls();
this.f11977a0.setVisibility(8);
if (this.X.isSeries()) {
App.getInstance().f11732q.edit().putString(a.b.C(this.X.getMovieId() + "" + this.f11986j0 + "" + this.f11987k0, "subtitle"), cVar.f13768a).apply();
} else {
App.getInstance().f11732q.edit().putString(this.X.getMovieId() + "subtitle", cVar.f13768a).apply();
}
ja.a.Success(getApplicationContext(), "Subtitles Loaded", null, 48, 0);
} else {
ja.a.Success(getApplicationContext(), "Only SRT and VTT format are supported. Please choose another file", null, 48, 1);
}
} catch (Exception unused) {
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(l lVar) {
int i10 = lVar.f13818a;
if (i10 > 0) {
this.Q.setSubColor(i10);
}
int i11 = lVar.f13819b;
if (i11 > 0) {
l(i11);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(n nVar) {
la.d dVar = this.f11999w0;
if (dVar != null) {
try {
dVar.dismiss();
} catch (Exception unused) {
}
}
ArrayList<m> arrayList = nVar.f13822a;
if (arrayList == null || arrayList.isEmpty()) {
i();
} else {
this.A0 = nVar.f13822a;
k();
}
}
@Override
public void onPause() {
super.onPause();
SessionManager sessionManager = this.f12001y0;
if (sessionManager != null) {
sessionManager.removeSessionManagerListener(this.f12002z0, CastSession.class);
this.f12000x0 = null;
}
}
@Override
public void onPaused(BetterVideoPlayer betterVideoPlayer) {
try {
if (this.f11981e0 != null) {
App.getInstance().f11732q.edit().putInt(this.f11981e0, betterVideoPlayer.getCurrentPosition()).apply();
}
if (this.f11982f0) {
this.H.removeCallbacks(this.I);
}
} catch (Exception e10) {
e10.printStackTrace();
}
}
@Override
public void onPrepared(BetterVideoPlayer betterVideoPlayer) {
Handler handler = new Handler();
Objects.requireNonNull(betterVideoPlayer);
handler.postDelayed(new aa.b(betterVideoPlayer, 2), 200L);
}
@Override
public void onPreparing() {
}
@Override
public void onResume() {
super.onResume();
if (App.getInstance().f11722g) {
this.B0 = -1;
this.A0 = new ArrayList<>();
App.getInstance().f11722g = false;
}
this.D = App.getInstance().f11732q.getBoolean("pref_show_time", true);
SessionManager sessionManager = this.f12001y0;
if (sessionManager != null) {
this.f12000x0 = sessionManager.getCurrentCastSession();
this.f12001y0.addSessionManagerListener(this.f12002z0, CastSession.class);
}
}
@Override
public void onStarted(BetterVideoPlayer betterVideoPlayer) {
if (this.f11989m0) {
return;
}
Movie movie = this.X;
if (movie != null && movie.isSeries() && this.f11982f0) {
h();
}
this.f11989m0 = true;
int i10 = this.f11993q0;
int i11 = 0;
if (i10 > 0) {
try {
betterVideoPlayer.seekTo(i10);
} catch (Exception unused) {
}
new Handler().postDelayed(new aa.e(this, i11), 1000L);
this.f11993q0 = -1;
}
if (this.f11991o0) {
try {
betterVideoPlayer.seekTo(this.f11990n0 - 5000);
} catch (Exception unused2) {
}
}
if (this.f11994r0) {
new Handler().postDelayed(new aa.b(betterVideoPlayer, 1), 500L);
this.f11994r0 = false;
}
}
@Override
public void onToggleControls(boolean z10) {
this.f11977a0.setAlpha(1.0f);
TextClock textClock = this.E;
if (textClock != null && this.D) {
textClock.setAlpha(1.0f);
this.E.setVisibility(z10 ? 0 : 8);
}
this.f11977a0.setVisibility(z10 ? 0 : 8);
if (!z10) {
if (this.f11984h0) {
g();
return;
}
return;
}
this.Q.showToolbar();
this.S.removeCallbacks(this.f11988l0);
this.S.postDelayed(this.f11988l0, 4000L);
if (!this.f11984h0 || this.f11978b0.getVisibility() == 0) {
return;
}
this.f11978b0.setVisibility(0);
this.f11978b0.startAnimation(this.f11995s0);
}
@Override
public void onWindowFocusChanged(boolean z10) {
super.onWindowFocusChanged(z10);
if (z10) {
this.P.setSystemUiVisibility(5894);
}
}
public void playLink(String str) {
try {
this.Q.reset();
this.Q.setSource(Uri.parse(str));
Movie movie = this.X;
String str2 = null;
if (movie != null && !movie.isSeries()) {
str2 = App.getInstance().f11732q.getString(this.X.getMovieId() + "subtitle", null);
} else if (this.X != null) {
String str3 = this.X.getMovieId() + "" + this.f11986j0 + "" + this.f11987k0;
str2 = App.getInstance().f11732q.getString(str3 + "subtitle", null);
}
if (str2 != null && new File(str2).exists()) {
this.Q.setCaptionsPath(str2, CaptionsView.CMime.SUBRIP, "");
}
this.f11984h0 = false;
this.H.removeCallbacks(this.I);
} catch (Exception e10) {
e10.printStackTrace();
}
}
public void requestAndDisplayAd() {
}
public final void showDialog() {
FragmentManager fragmentManager = getFragmentManager();
la.d newInstance = la.d.newInstance(this, true);
newInstance.setTitle("Exit");
newInstance.setMessage("Do you really want to stop playback and exit ?");
newInstance.setButton1("CANCEL", new y(17));
newInstance.setButton2("YES", new aa.f(this, 0));
try {
newInstance.show(fragmentManager, "");
} catch (Exception e10) {
e10.printStackTrace();
}
}
}