mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +01:00
Fix gfycat videos cannot be played after clicking the preview or fullscreen in PostRecyclerViewAdapter and CommentAndPostRecyclerViewAdapter.
This commit is contained in:
parent
52ee70a57e
commit
05e3889fe7
@ -33,7 +33,6 @@ import com.google.android.exoplayer2.Player;
|
|||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.source.dash.DashMediaSource;
|
|
||||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
@ -217,6 +216,8 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
mVideoUri = Uri.parse(videoUrl);
|
mVideoUri = Uri.parse(videoUrl);
|
||||||
videoDownloadUrl = savedInstanceState.getString(VIDEO_DOWNLOAD_URL_STATE);
|
videoDownloadUrl = savedInstanceState.getString(VIDEO_DOWNLOAD_URL_STATE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mVideoUri = intent.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVideoUri == null) {
|
if (mVideoUri == null) {
|
||||||
@ -234,7 +235,7 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
dataSourceFactory = new DefaultDataSourceFactory(ViewVideoActivity.this,
|
dataSourceFactory = new DefaultDataSourceFactory(ViewVideoActivity.this,
|
||||||
Util.getUserAgent(ViewVideoActivity.this, "Infinity"));
|
Util.getUserAgent(ViewVideoActivity.this, "Infinity"));
|
||||||
player.prepare(new DashMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
}
|
}
|
||||||
} else if (videoType == VIDEO_TYPE_DIRECT) {
|
} else if (videoType == VIDEO_TYPE_DIRECT) {
|
||||||
|
@ -2353,10 +2353,25 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
fullscreenButton.setOnClickListener(view -> {
|
fullscreenButton.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
|
if (mPost.isGfycat()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
||||||
|
if (mPost.isLoadGfyOrRedgifsVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
|
}
|
||||||
|
} else if (mPost.isRedgifs()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
||||||
|
if (mPost.isLoadGfyOrRedgifsVideoSuccess()) {
|
||||||
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||||
|
}
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition());
|
intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
||||||
@ -2551,10 +2566,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mImageView.setOnClickListener(view -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
if (mPost.getPostType() == Post.VIDEO_TYPE) {
|
if (mPost.getPostType() == Post.VIDEO_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
|
if (mPost.isGfycat()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
||||||
|
} else if (mPost.isRedgifs()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
||||||
|
} else {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
|
}
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
|
@ -1868,10 +1868,26 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
|
if (post.isGfycat()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
|
if (post.isLoadGfyOrRedgifsVideoSuccess()) {
|
||||||
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
|
}
|
||||||
|
} else if (post.isRedgifs()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
|
if (post.isLoadGfyOrRedgifsVideoSuccess()) {
|
||||||
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
||||||
|
}
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition());
|
intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
|
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
|
||||||
@ -2081,10 +2097,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
|
if (post.isGfycat()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
|
} else if (post.isRedgifs()) {
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
|
} else {
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
|
}
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
|
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
|
Loading…
Reference in New Issue
Block a user