mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +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);
|
||||
} else if (path.endsWith("gifv") || path.endsWith("mp4")) {
|
||||
String url = uri.toString();
|
||||
// Insecure imgur links won't load
|
||||
url = url.replaceFirst("http://" , "https://");
|
||||
if (path.endsWith("gifv")) {
|
||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
loadStreamableVideo(shortCode, savedInstanceState);
|
||||
} else {
|
||||
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.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||
preparePlayer(savedInstanceState);
|
||||
@ -536,7 +536,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
}
|
||||
} else {
|
||||
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.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||
preparePlayer(savedInstanceState);
|
||||
@ -550,7 +550,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
}
|
||||
// Produces DataSource instances through which media data is loaded.
|
||||
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.
|
||||
player.prepare();
|
||||
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";
|
||||
// Produces DataSource instances through which media data is loaded.
|
||||
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.
|
||||
player.prepare();
|
||||
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);
|
||||
videoDownloadUrl = mp4;
|
||||
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);
|
||||
player.prepare();
|
||||
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);
|
||||
videoDownloadUrl = mp4;
|
||||
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);
|
||||
player.prepare();
|
||||
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);
|
||||
// Produces DataSource instances through which media data is loaded.
|
||||
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.
|
||||
player.prepare();
|
||||
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";
|
||||
// Produces DataSource instances through which media data is loaded.
|
||||
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.
|
||||
preparePlayer(savedInstanceState);
|
||||
player.prepare();
|
||||
@ -848,7 +848,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
||||
mVideoUri = Uri.parse(videoDownloadUrl);
|
||||
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);
|
||||
player.prepare();
|
||||
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();
|
||||
videoPlayerView.setPlayer(player);
|
||||
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.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();
|
||||
videoPlayerView.setPlayer(player);
|
||||
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.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(galleryVideo.url)));
|
||||
|
||||
|
@ -379,9 +379,6 @@ public class ParsePost {
|
||||
String authority = uri.getAuthority();
|
||||
// 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"))) {
|
||||
// Insecure imgur links won't load
|
||||
url = url.replaceFirst("http://" , "https://");
|
||||
|
||||
if (url.endsWith("gifv")) {
|
||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||
}
|
||||
@ -438,8 +435,6 @@ public class ParsePost {
|
||||
// Imgur gifv/mp4
|
||||
int postType = Post.VIDEO_TYPE;
|
||||
|
||||
// Insecure imgur links won't load
|
||||
url = url.replaceFirst("http://" , "https://");
|
||||
if (url.endsWith("gifv")) {
|
||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class DefaultExoCreator implements ExoCreator, MediaSourceEventListener {
|
||||
|
||||
DataSource.Factory baseFactory = config.dataSourceFactory;
|
||||
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);
|
||||
if (config.cache != null)
|
||||
|
Loading…
Reference in New Issue
Block a user