From dc4fa2e6b8e27e987e8730e5d5e26a0dd2a0411d Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 20 Dec 2021 21:50:26 +0800 Subject: Handle Streamable and Imgur videos when parsing v.redd.it videos in ViewVideoActivity. --- .../activities/LinkResolverActivity.java | 2 +- .../infinityforreddit/activities/ViewVideoActivity.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index a8c609f2..6e744fd4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -265,7 +265,7 @@ public class LinkResolverActivity extends AppCompatActivity { url = url.replaceFirst("http://" , "https://"); url = url.substring(0, url.length() - 5) + ".mp4"; Intent intent = new Intent(this, ViewVideoActivity.class); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT); + intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); intent.setData(Uri.parse(url)); startActivity(intent); 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 b53ddf7e..9431ca29 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -721,6 +721,22 @@ public class ViewVideoActivity extends AppCompatActivity { videoFileName = "Redgifs-" + gfycatId + ".mp4"; } loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, savedInstanceState, false); + } else if (post.isStreamable()) { + videoType = VIDEO_TYPE_STREAMABLE; + String shortCode = post.getStreamableShortCode(); + videoFileName = "Streamable-" + shortCode + ".mp4"; + loadStreamableVideo(shortCode, savedInstanceState); + } else if (post.isImgur()) { + mVideoUri = Uri.parse(post.getVideoUrl()); + videoDownloadUrl = post.getVideoDownloadUrl(); + videoType = VIDEO_TYPE_IMGUR; + videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl); + // Produces DataSource instances through which media data is loaded. + dataSourceFactory = new CacheDataSourceFactory(mSimpleCache, + new DefaultHttpDataSourceFactory(Util.getUserAgent(ViewVideoActivity.this, "Infinity"))); + // Prepare the player with the source. + player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri)); + preparePlayer(savedInstanceState); } else { progressBar.setVisibility(View.GONE); if (post.getVideoUrl() != null) { -- cgit v1.2.3