diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-02-24 14:29:32 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-02-24 14:29:32 +0000 |
commit | 5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40 (patch) | |
tree | 106cf5efa5b3beb135e87fb428f84e7f3652500e /app | |
parent | 4b167f91bc6facaa9f35a2a38ce0fc017cb8974a (diff) | |
download | infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.tar infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.tar.gz infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.tar.bz2 infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.tar.lz infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.tar.xz infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.tar.zst infinity-for-reddit-5d41c996b0c2d5d2a951fd81b57355c6fdfd0f40.zip |
Use mp4 version of the fallback video.
Diffstat (limited to 'app')
3 files changed, 19 insertions, 16 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index ba3a9c15..d827bcc8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -184,7 +184,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe private String videoDownloadUrl; private String videoFileName; - private String videoFallbackHLSUrl; + private String videoFallbackDirectUrl; private String subredditName; private String id; private boolean wasPlaying; @@ -411,7 +411,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe Post post = intent.getParcelableExtra(EXTRA_POST); if (post != null) { titleTextView.setText(post.getTitle()); - videoFallbackHLSUrl = post.getVideoFallBackHLSUrl(); + videoFallbackDirectUrl = post.getVideoFallBackDirectUrl(); } trackSelector = new DefaultTrackSelector(this); @@ -757,7 +757,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe new FetchPost.FetchPostListener() { @Override public void fetchPostSuccess(Post post) { - videoFallbackHLSUrl = post.getVideoFallBackHLSUrl(); + videoFallbackDirectUrl = post.getVideoFallBackDirectUrl(); if (post.isRedgifs()) { videoType = VIDEO_TYPE_REDGIFS; String redgifsId = post.getRedgifsId(); @@ -851,12 +851,15 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } private void loadFallbackVideo(Bundle savedInstanceState) { - if (videoFallbackHLSUrl != null) { + if (videoFallbackDirectUrl != null) { MediaItem mediaItem = player.getCurrentMediaItem(); - if (mediaItem == null || mediaItem.localConfiguration != null && !videoFallbackHLSUrl.equals(mediaItem.localConfiguration.uri.toString())) { - videoType = VIDEO_TYPE_NORMAL; + if (mediaItem == null || mediaItem.localConfiguration != null && !videoFallbackDirectUrl.equals(mediaItem.localConfiguration.uri.toString())) { + videoType = VIDEO_TYPE_DIRECT; + videoDownloadUrl = videoFallbackDirectUrl; + mVideoUri = Uri.parse(videoFallbackDirectUrl); + videoFileName = FilenameUtils.getName(videoDownloadUrl); player.prepare(); - player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(videoFallbackHLSUrl))); + player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); preparePlayer(savedInstanceState); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index c0a65008..6c786189 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -399,8 +399,8 @@ public class ParsePost { post.setVideoUrl(videoUrl); post.setVideoDownloadUrl(videoDownloadUrl); } - post.setVideoFallBackHLSUrl(Html.fromHtml(data.getJSONObject(JSONUtils.PREVIEW_KEY) - .getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.HLS_URL_KEY)).toString()); + post.setVideoFallBackDirectUrl(Html.fromHtml(data.getJSONObject(JSONUtils.PREVIEW_KEY) + .getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.FALLBACK_URL_KEY)).toString()); } else { if (path.endsWith(".jpg") || path.endsWith(".png") || path.endsWith(".jpeg")) { //Image post diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index e8fc7ee1..d15c6f7e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -43,7 +43,7 @@ public class Post implements Parcelable { private String url; private String videoUrl; private String videoDownloadUrl; - private String videoFallBackHLSUrl; + private String videoFallBackDirectUrl; private String redgifsId; private String streamableShortCode; private boolean isImgur; @@ -168,7 +168,7 @@ public class Post implements Parcelable { url = in.readString(); videoUrl = in.readString(); videoDownloadUrl = in.readString(); - videoFallBackHLSUrl = in.readString(); + videoFallBackDirectUrl = in.readString(); redgifsId = in.readString(); streamableShortCode = in.readString(); isImgur = in.readByte() != 0; @@ -330,12 +330,12 @@ public class Post implements Parcelable { this.videoDownloadUrl = videoDownloadUrl; } - public String getVideoFallBackHLSUrl() { - return videoFallBackHLSUrl; + public String getVideoFallBackDirectUrl() { + return videoFallBackDirectUrl; } - public void setVideoFallBackHLSUrl(String videoFallBackHLSUrl) { - this.videoFallBackHLSUrl = videoFallBackHLSUrl; + public void setVideoFallBackDirectUrl(String videoFallBackDirectUrl) { + this.videoFallBackDirectUrl = videoFallBackDirectUrl; } public String getRedgifsId() { @@ -498,7 +498,7 @@ public class Post implements Parcelable { dest.writeString(url); dest.writeString(videoUrl); dest.writeString(videoDownloadUrl); - dest.writeString(videoFallBackHLSUrl); + dest.writeString(videoFallBackDirectUrl); dest.writeString(redgifsId); dest.writeString(streamableShortCode); dest.writeByte((byte) (isImgur ? 1 : 0)); |