Fix: Allow fallback for unknown URL schemes #230
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses an issue where some videos fail to play on Android TV because the browser incorrectly handles custom URL schemes, preventing websites from executing their fallback playback mechanisms.
The Problem
On certain websites (e.g., fmovies), clicking the play button on a video first attempts to launch an external application via a custom URL scheme (such as
hobs://...).On Android mobile, if the corresponding app is not installed, the OS fails to handle the URL, but the browser gracefully ignores it. This allows the website's JavaScript to proceed with its fallback plan, which is to play the video directly within the browser's webview.
On Android TV, the current implementation behaves differently. When no app is found to handle the custom URL, the browser attempts to load the URL anyway, leading to a
net::ERR_UNKNOWN_URL_SCHEMEerror page. This hard stop prevents the website's fallback script from ever running, leaving the user unable to play the video.The Solution
The fix is a minor but crucial change in the
shouldOverrideUrlLoadingmethod withinMainActivity.kt.By changing the return value from
falsetotruein the else block (which is executed whenintent.resolveActivity()returnsnull), we instruct the webview to ignore the unhandled URL scheme instead of trying to load it.This change makes the Android TV behavior consistent with the mobile behavior, allowing the website's video player to use its intended fallback and play the content successfully.
How to Test This Change
https://fmoviesunblocked.net/spa/videoPlayPage/movies/forrest-gump-omjDmakRI3?id=50406015359143712&type=/movie/detail&lang=ennet::ERR_UNKNOWN_URL_SCHEME).This simple change significantly improves compatibility with modern websites and enhances the user experience on TV devices.