Handle Streamable and Imgur videos when parsing v.redd.it videos in ViewVideoActivity.

This commit is contained in:
Alex Ning 2021-12-20 21:50:26 +08:00
parent 7150ac6981
commit dc4fa2e6b8
2 changed files with 17 additions and 1 deletions

View File

@ -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);

View File

@ -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) {