aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java14
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));