Skip to content

[pull] master from yuliskov:master #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void onEngineError(int type, int rendererIndex, Throwable error) {
Log.e(TAG, "Player error occurred: %s. Trying to fix…", type);

mLastErrorType = type;
runErrorAction(type, rendererIndex, error);
runEngineErrorAction(type, rendererIndex, error);
}

@Override
Expand Down Expand Up @@ -310,24 +310,7 @@ private void loadFormatInfo(Video video) {
.subscribe(this::processFormatInfo,
error -> {
getPlayer().showProgressBar(false);
String message = error.getMessage();
String className = error.getClass().getSimpleName();
Log.e(TAG, "loadFormatInfo error: %s", message);
if (!Helpers.containsAny(message, "fromNullable result is null")) {
MessageHelpers.showLongMessage(getContext(), "%s: %s", className, message);
}

if (Helpers.containsAny(message, "Unexpected token", "Syntax error", "invalid argument") || // temporal fix
Helpers.equalsAny(className, "PoTokenException", "BadWebViewException")) {
YouTubeServiceManager.instance().applyNoPlaybackFix();
reloadVideo();
} else if (Helpers.containsAny(message, "is not defined")) {
YouTubeServiceManager.instance().invalidateCache();
reloadVideo();
} else {
Log.e(TAG, "Probably no internet connection");
scheduleReloadVideoTimer(1_000);
}
runFormatErrorAction(error);
});
}

Expand Down Expand Up @@ -473,9 +456,45 @@ private void disposeActions() {
Utils.removeCallbacks(mReloadVideo, mLoadNext, mRestartEngine, mMetadataSync, mOnLongBuffering, mRebootApp);
}

@SuppressLint("StringFormatMatches")
private void runErrorAction(int type, int rendererIndex, Throwable error) {
boolean restart = applyGenericErrorAction(type, rendererIndex, error);
private void runFormatErrorAction(Throwable error) {
if (mLastVideo != null && mLastVideo.embedPlayer) {
if (getPlayer() != null) {
getPlayer().finish();
}
return;
}

String message = error.getMessage();
String className = error.getClass().getSimpleName();
String fullMsg = String.format("loadFormatInfo error: %s: %s", className, message);
Log.e(TAG, fullMsg);

if (!Helpers.containsAny(message, "fromNullable result is null")) {
MessageHelpers.showLongMessage(getContext(), fullMsg);
}

if (Helpers.containsAny(message, "Unexpected token", "Syntax error", "invalid argument") || // temporal fix
Helpers.equalsAny(className, "PoTokenException", "BadWebViewException")) {
YouTubeServiceManager.instance().applyNoPlaybackFix();
reloadVideo();
} else if (Helpers.containsAny(message, "is not defined")) {
YouTubeServiceManager.instance().invalidateCache();
reloadVideo();
} else {
Log.e(TAG, "Probably no internet connection");
scheduleReloadVideoTimer(1_000);
}
}

private void runEngineErrorAction(int type, int rendererIndex, Throwable error) {
if (mLastVideo != null && mLastVideo.embedPlayer) {
if (getPlayer() != null) {
getPlayer().finish();
}
return;
}

boolean restart = applyEngineErrorAction(type, rendererIndex, error);

if (restart) {
restartEngine();
Expand All @@ -484,7 +503,7 @@ private void runErrorAction(int type, int rendererIndex, Throwable error) {
}
}

private boolean applyGenericErrorAction(int type, int rendererIndex, Throwable error) {
private boolean applyEngineErrorAction(int type, int rendererIndex, Throwable error) {
boolean restartEngine = true;
String message = error != null ? error.getMessage() : null;
String errorTitle = getErrorTitle(type, rendererIndex);
Expand All @@ -493,7 +512,7 @@ private boolean applyGenericErrorAction(int type, int rendererIndex, Throwable e
String resultMsg = fullErrorMsg;

if (Helpers.startsWithAny(message, "Unable to connect to")) {
// No internet connection
// No internet connection or WRONG DATE on the device
restartEngine = false;
resultMsg = shortErrorMsg;
} else if (error instanceof OutOfMemoryError) {
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,7 @@
<string name="premium_users_only">Nur für Premium-Nutzer. Fix für unvollständige Videoformat-Liste</string>
<string name="playback_buffering_fix">Wiedergabe-Puffer-Fix</string>
<string name="oculus_quest_fix">Oculus-Quest-Fix</string>
<string name="card_preview_muted">Video ohne Ton</string>
<string name="card_preview_full">Video mit Ton</string>
<string name="card_preview">Karten-Vorschau</string>
</resources>
4 changes: 2 additions & 2 deletions smarttubetv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ android {
applicationId "com.liskovsoft.smarttubetv"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 1952
versionName "27.62"
versionCode 1953
versionName "27.63"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"

Expand Down