mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Allow https redirection in ExoPlayer (#1261)
This commit is contained in:
parent
bc03d20845
commit
c7c9727bac
@ -301,8 +301,6 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.endsWith("gifv") || path.endsWith("mp4")) {
|
} else if (path.endsWith("gifv") || path.endsWith("mp4")) {
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
// Insecure imgur links won't load
|
|
||||||
url = url.replaceFirst("http://" , "https://");
|
|
||||||
if (path.endsWith("gifv")) {
|
if (path.endsWith("gifv")) {
|
||||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
loadStreamableVideo(shortCode, savedInstanceState);
|
loadStreamableVideo(shortCode, savedInstanceState);
|
||||||
} else {
|
} else {
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
@ -536,7 +536,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
@ -550,7 +550,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
}
|
}
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -562,7 +562,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoFileName = subredditName + "-" + id + ".mp4";
|
videoFileName = subredditName + "-" + id + ".mp4";
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -693,7 +693,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
mVideoUri = Uri.parse(webm);
|
mVideoUri = Uri.parse(webm);
|
||||||
videoDownloadUrl = mp4;
|
videoDownloadUrl = mp4;
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -723,7 +723,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
mVideoUri = Uri.parse(webm);
|
mVideoUri = Uri.parse(webm);
|
||||||
videoDownloadUrl = mp4;
|
videoDownloadUrl = mp4;
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -789,7 +789,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl);
|
videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl);
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -805,7 +805,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoFileName = subredditName + "-" + id + ".mp4";
|
videoFileName = subredditName + "-" + id + ".mp4";
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
@ -848,7 +848,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
||||||
mVideoUri = Uri.parse(videoDownloadUrl);
|
mVideoUri = Uri.parse(videoDownloadUrl);
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
|
@ -148,7 +148,7 @@ public class ViewImgurVideoFragment extends Fragment {
|
|||||||
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
||||||
videoPlayerView.setPlayer(player);
|
videoPlayerView.setPlayer(player);
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(imgurMedia.getLink())));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(imgurMedia.getLink())));
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
|
|||||||
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
||||||
videoPlayerView.setPlayer(player);
|
videoPlayerView.setPlayer(player);
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(galleryVideo.url)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(galleryVideo.url)));
|
||||||
|
|
||||||
|
@ -379,9 +379,6 @@ public class ParsePost {
|
|||||||
String authority = uri.getAuthority();
|
String authority = uri.getAuthority();
|
||||||
// The hls stream inside REDDIT_VIDEO_PREVIEW_KEY can sometimes lack an audio track
|
// The hls stream inside REDDIT_VIDEO_PREVIEW_KEY can sometimes lack an audio track
|
||||||
if (authority.contains("imgur.com") && (url.endsWith(".gifv") || url.endsWith(".mp4"))) {
|
if (authority.contains("imgur.com") && (url.endsWith(".gifv") || url.endsWith(".mp4"))) {
|
||||||
// Insecure imgur links won't load
|
|
||||||
url = url.replaceFirst("http://" , "https://");
|
|
||||||
|
|
||||||
if (url.endsWith("gifv")) {
|
if (url.endsWith("gifv")) {
|
||||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||||
}
|
}
|
||||||
@ -438,8 +435,6 @@ public class ParsePost {
|
|||||||
// Imgur gifv/mp4
|
// Imgur gifv/mp4
|
||||||
int postType = Post.VIDEO_TYPE;
|
int postType = Post.VIDEO_TYPE;
|
||||||
|
|
||||||
// Insecure imgur links won't load
|
|
||||||
url = url.replaceFirst("http://" , "https://");
|
|
||||||
if (url.endsWith("gifv")) {
|
if (url.endsWith("gifv")) {
|
||||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class DefaultExoCreator implements ExoCreator, MediaSourceEventListener {
|
|||||||
|
|
||||||
DataSource.Factory baseFactory = config.dataSourceFactory;
|
DataSource.Factory baseFactory = config.dataSourceFactory;
|
||||||
if (baseFactory == null) {
|
if (baseFactory == null) {
|
||||||
baseFactory = new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT);
|
baseFactory = new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT);
|
||||||
}
|
}
|
||||||
DataSource.Factory factory = new DefaultDataSource.Factory(this.toro.context, baseFactory);
|
DataSource.Factory factory = new DefaultDataSource.Factory(this.toro.context, baseFactory);
|
||||||
if (config.cache != null)
|
if (config.cache != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user