From 74982a4608a8f58f4995f92fba5a187cc3577f4a Mon Sep 17 00:00:00 2001 From: guoshuyu <359369982@qq.com> Date: Tue, 21 May 2019 14:13:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20allowCrossProtocolRedirect?= =?UTF-8?q?s=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/gsyvideoplayer/DetailPlayer.java | 3 ++- .../ijk/media/exo2/ExoSourceManager.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java b/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java index 1f15ecd..abf7b89 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java +++ b/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java @@ -84,12 +84,13 @@ public class DetailPlayer extends AppCompatActivity { Map header = new HashMap<>(); header.put("ee", "33"); + header.put("allowCrossProtocolRedirects", "true"); GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder(); gsyVideoOption.setThumbImageView(imageView) .setIsTouchWiget(true) .setRotateViewAuto(false) .setLockLand(false) - .setAutoFullWithSize(true) + .setAutoFullWithSize(false) .setShowFullAnimation(false) .setNeedLockFull(true) .setUrl(url) diff --git a/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java b/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java index 27395df..38b0013 100644 --- a/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java +++ b/gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java @@ -3,7 +3,10 @@ package tv.danmaku.ijk.media.exo2; import android.annotation.SuppressLint; import android.content.Context; import android.net.Uri; + import androidx.annotation.Nullable; + +import tv.danmaku.ijk.media.exo2.source.GSYExoHttpDataSource; import tv.danmaku.ijk.media.exo2.source.GSYExoHttpDataSourceFactory; import android.text.TextUtils; @@ -230,6 +233,7 @@ public class ExoSourceManager { /** * 设置https忽略证书 + * * @param skipSSLChain true时是hulve */ public static void setSkipSSLChain(boolean skipSSLChain) { @@ -259,18 +263,24 @@ public class ExoSourceManager { } private DataSource.Factory getHttpDataSourceFactory(Context context, boolean preview) { - if(mSkipSSLChain) { + boolean allowCrossProtocolRedirects = false; + if (mMapHeadData != null && mMapHeadData.size() > 0) { + allowCrossProtocolRedirects = "true".equals(mMapHeadData.get("allowCrossProtocolRedirects")); + } + if (mSkipSSLChain) { GSYExoHttpDataSourceFactory dataSourceFactory = new GSYExoHttpDataSourceFactory(Util.getUserAgent(context, - TAG), preview ? null : new DefaultBandwidthMeter()); + TAG), preview ? null : new DefaultBandwidthMeter(), GSYExoHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, + GSYExoHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects); if (mMapHeadData != null && mMapHeadData.size() > 0) { for (Map.Entry header : mMapHeadData.entrySet()) { dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue()); } } - return dataSourceFactory; + return dataSourceFactory; } DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(context, - TAG), preview ? null : new DefaultBandwidthMeter()); + TAG), preview ? null : new DefaultBandwidthMeter(), GSYExoHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, + GSYExoHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects); if (mMapHeadData != null && mMapHeadData.size() > 0) { for (Map.Entry header : mMapHeadData.entrySet()) { dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue()); -- GitLab