From d5e95292dfe8ee83df63bc5166c70788b71491ea Mon Sep 17 00:00:00 2001 From: guoshuyu <359369982@qq.com> Date: Mon, 23 Nov 2020 10:25:26 +0800 Subject: [PATCH] fix #3047 --- .../java/com/example/gsyvideoplayer/DetailPlayer.java | 2 +- .../example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java | 8 ++++++-- .../gsyvideoplayer/exosubtitle/GSYExoSubTitlePlayer.java | 7 +++++-- 3 files changed, 12 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 2d981073c..7b3de653d 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java +++ b/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java @@ -326,7 +326,7 @@ private String getUrl() { //String url = "http://yongtaizx.xyz/20191230/t2Axgh3k/index.m3u8"; //String url = "http://123.56.109.212:8035/users/bfe52074fba74247853caa764b522731/films/orig/aa4c3451-0468-452a-a189-bd064a1963e5-鹿鼎记下.mp4"; //String url = "http://static.hnyequ.cn/yequ_iOS/4940735da1227890e6a261937223e0d2_828x1472.mp4"; - String url = "https://tx.hls.huya.com/src/78941969-2579769454-11080025436149776384-3144993630-10057-A-0-1-imgplus_2000.m3u8?wsSecret=3e6b5903368d02d0c591a57a07940cca&wsTime=5f4ca52f&u=0&seqid=15987721445850596&ctype=tars_mobile&fs=bgct&sphdcdn=al_7-tx_3-js_3-ws_7-bd_2-hw_2&sphdDC=huya&sphd=264_*&t=103"; + String url = "http://39.104.119.42/elevator-1.0/api/downFile?path=demo.ogv"; //String url = "http://pointshow.oss-cn-hangzhou.aliyuncs.com/transcode/ORIGINAL/Mnbc61586842828593.mp4"; //ssl error //String url = "https://file.shftz.cn:8443/filesystem/download/10/2019/3/26/ce2c7c66-e9eb-42be-adf6-f9008385ea8c.mov/play"; diff --git a/app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java b/app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java index a54ce90ab..0d21d0a6d 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java +++ b/app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java @@ -8,7 +8,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultRenderersFactory; -import com.google.android.exoplayer2.ExoPlayerFactory; +import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.source.ConcatenatingMediaSource; import com.google.android.exoplayer2.source.MediaSource; @@ -134,7 +134,11 @@ public void run() { if (mLoadControl == null) { mLoadControl = new DefaultLoadControl(); } - mInternalPlayer = ExoPlayerFactory.newSimpleInstance(mAppContext, mRendererFactory, mTrackSelector, mLoadControl, null, Looper.getMainLooper()); + mInternalPlayer = new SimpleExoPlayer.Builder(mAppContext, mRendererFactory) + .setLooper(Looper.getMainLooper()) + .setTrackSelector(mTrackSelector) + .setLoadControl(mLoadControl).build(); + mInternalPlayer.addListener(GSYExo2MediaPlayer.this); mInternalPlayer.addAnalyticsListener(GSYExo2MediaPlayer.this); mInternalPlayer.addListener(mEventLogger); diff --git a/app/src/main/java/com/example/gsyvideoplayer/exosubtitle/GSYExoSubTitlePlayer.java b/app/src/main/java/com/example/gsyvideoplayer/exosubtitle/GSYExoSubTitlePlayer.java index db247d74f..dbd37943c 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/exosubtitle/GSYExoSubTitlePlayer.java +++ b/app/src/main/java/com/example/gsyvideoplayer/exosubtitle/GSYExoSubTitlePlayer.java @@ -8,8 +8,8 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultRenderersFactory; -import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.Format; +import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MergingMediaSource; import com.google.android.exoplayer2.source.SingleSampleMediaSource; @@ -58,7 +58,10 @@ public void run() { if (mLoadControl == null) { mLoadControl = new DefaultLoadControl(); } - mInternalPlayer = ExoPlayerFactory.newSimpleInstance(mAppContext, mRendererFactory, mTrackSelector, mLoadControl, null, Looper.getMainLooper()); + mInternalPlayer = new SimpleExoPlayer.Builder(mAppContext, mRendererFactory) + .setLooper(Looper.getMainLooper()) + .setTrackSelector(mTrackSelector) + .setLoadControl(mLoadControl).build(); mInternalPlayer.addListener(GSYExoSubTitlePlayer.this); mInternalPlayer.addAnalyticsListener(GSYExoSubTitlePlayer.this); if (mTextOutput != null) {