Skip to content

Commit df5803c

Browse files
committed
修复已知BUG,失效资源替换
1 parent fe3bb04 commit df5803c

32 files changed

+148
-120
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#### 三、SDK集成
2626
* 建议集成前先[下载apk][2]体验,找到自己想要实现的功能模块,后续集成可参考demo源码。
2727

28-
[2]:https://amuse-1259486925.cos.ap-hongkong.myqcloud.com/apk/iPlayer-2.1.2.apk?version=2.1.2 "下载apk"
28+
[2]:https://amuse-1259486925.cos.ap-hongkong.myqcloud.com/apk/iPlayer-2.1.21.apk?version=2.1.21 "下载apk"
2929

3030
##### 1、项目根build.gradle配置</br>
3131
```
@@ -39,17 +39,17 @@
3939
```
4040
dependencies {
4141
//播放器(无UI交互)
42-
implementation 'com.github.hty527.iPlayer:iplayer:2.1.20'
42+
implementation 'com.github.hty527.iPlayer:iplayer:2.1.21'
4343
//UI交互组件,可根据需要使用
44-
implementation 'com.github.hty527.iPlayer:widget:2.1.20'
44+
implementation 'com.github.hty527.iPlayer:widget:2.1.21'
4545
4646
//音视频预缓存+边播边存,根据需要使用
47-
//implementation 'com.github.hty527.iPlayer:cache:2.1.20'
47+
//implementation 'com.github.hty527.iPlayer:cache:2.1.21'
4848
4949
//ijk音视频解码器,根据需要使用
50-
//implementation 'com.github.hty527.iPlayer:ijk:2.1.20'
50+
//implementation 'com.github.hty527.iPlayer:ijk:2.1.21'
5151
//exo音视频解码器,根据需要使用
52-
//implementation 'com.github.hty527.iPlayer:exo:2.1.20'
52+
//implementation 'com.github.hty527.iPlayer:exo:2.1.21'
5353
//选择exo音视频解码器时需引用
5454
//以下为必须项,SDK内部已引用,集成时无需引用
5555
//implementation 'com.google.android.exoplayer:exoplayer:2.18.1'//(必需)

app/build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ dependencies {
7878
implementation 'com.google.code.gson:gson:2.8.5'
7979

8080
//播放器SDK
81-
implementation 'com.github.hty527.iPlayer:iplayer:2.1.20'
81+
implementation 'com.github.hty527.iPlayer:iplayer:2.1.21'
8282
//UI交互组件,可根据需要使用
83-
implementation 'com.github.hty527.iPlayer:widget:2.1.20'
83+
implementation 'com.github.hty527.iPlayer:widget:2.1.21'
8484
//音视频预缓存+边播边存,根据需要使用
85-
implementation 'com.github.hty527.iPlayer:cache:2.1.20'
85+
implementation 'com.github.hty527.iPlayer:cache:2.1.21'
8686
//ijk音视频解码器,根据自己需要实现
87-
implementation 'com.github.hty527.iPlayer:ijk:2.1.20'
87+
implementation 'com.github.hty527.iPlayer:ijk:2.1.21'
8888
//exo音视频解码器,根据自己需要实现
89-
implementation 'com.github.hty527.iPlayer:exo:2.1.20'
89+
implementation 'com.github.hty527.iPlayer:exo:2.1.21'
9090

9191
// //播放器SDK
9292
// implementation project(':iplayer')
@@ -96,7 +96,7 @@ dependencies {
9696
// implementation project(':cache')
9797
// //ijk音视频解码器
9898
// implementation project(':ijk')
99-
//exo音视频解码器
99+
// //exo音视频解码器
100100
// implementation project(':exo')
101101

102102
//以下为必须项,SDK内部已引用

app/src/main/java/com/android/videoplayer/base/BaseActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class BaseActivity <P extends BasePresenter> extends AppCompatAc
3030
/**
3131
* 点播测试流,以下格式视频流已测试支持
3232
*/
33-
public static final String MP4_URL0 ="http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4";//惊奇队长预告
33+
public static final String MP4_URL0 ="https://vd3.bdstatic.com/mda-pd736fppd4m1muub/sc/cae_h264/1680924082856978562/mda-pd736fppd4m1muub.mp4";//惊奇队长2预告
3434
public static final String MP4_URL1 ="http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4";//叶问1预告
3535
public static final String MP4_URL2 ="https://upload.dongfeng-nissan.com.cn/nissan/video/202204/4cfde6f0-bf80-11ec-95c3-214c38efbbc8.mp4";//2021款第七代天籁
3636
public static final String MP4_URL3 ="http://cdnxdc.tanzi88.com/XDC/dvideo/2017/11/29/15f22f48466180232ca50ec25b0711a7.mp4";//网络视频-七舅脑爷

app/src/main/java/com/android/videoplayer/pager/activity/PagerPlayerActivity.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4747
setFullScreen(true);
4848
super.onCreate(savedInstanceState);
4949
setContentView(R.layout.activity_pager_simple);
50-
StatusUtils.setStatusTextColor1(true, PagerPlayerActivity.this);//黑色字体
50+
51+
View statusBar = findViewById(R.id.status_bar);
5152
findViewById(R.id.status_bar).getLayoutParams().height= ScreenUtils.getInstance().getStatusBarHeight(getApplicationContext());
53+
StatusUtils.setStatusTextColor1(true, PagerPlayerActivity.this);//黑色字体
5254

5355
mBtnBack = (ImageView) findViewById(R.id.btn_back);
5456
mBtnBack.setColorFilter(Color.parseColor("#333333"));

app/src/main/java/com/android/videoplayer/pager/fragment/VideoListFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected int getLayoutID() {
3232

3333
@Override
3434
protected void initViews() {
35-
ImageView status_bar = (ImageView) findViewById(R.id.status_bar);
35+
ImageView status_bar = (ImageView) findViewById(R.id.bar_image);
3636
status_bar.getLayoutParams().height= ScreenUtils.getInstance().getStatusBarHeight(getContext())+ScreenUtils.getInstance().dpToPxInt(49f);
3737
status_bar.setImageResource(R.mipmap.ic_title_bg);
3838
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

app/src/main/java/com/android/videoplayer/pager/widget/ViewPagerLayoutManager.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ public void onScrollStateChanged(int state) {
5050
if (state == RecyclerView.SCROLL_STATE_IDLE) {
5151
if(null!=mPagerSnapHelper){
5252
View viewIdle = mPagerSnapHelper.findSnapView(ViewPagerLayoutManager.this);
53-
int position = getPosition(viewIdle);
54-
Logger.d(TAG,"onScrollStateChanged-->position:"+position+",currentPostion:"+mCurrentPostion);
55-
//过滤重复选中
56-
if (mOnViewPagerListener != null && this.mCurrentPostion != position) {
57-
this.mCurrentPostion = position;
58-
mOnViewPagerListener.onPageSelected(viewIdle, position,position==getItemCount()-2);
53+
if(null!=viewIdle){
54+
int position = getPosition(viewIdle);
55+
Logger.d(TAG,"onScrollStateChanged-->position:"+position+",currentPostion:"+mCurrentPostion);
56+
//过滤重复选中
57+
if (mOnViewPagerListener != null && this.mCurrentPostion != position) {
58+
this.mCurrentPostion = position;
59+
mOnViewPagerListener.onPageSelected(viewIdle, position,position==getItemCount()-2);
60+
}
5961
}
6062
}
6163
}

app/src/main/java/com/android/videoplayer/ui/activity/VideosPlayerActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void onGlobalLayout() {
7777
});
7878
mCorePlayerViews.add(corePlayerView);
7979
mPlayerContainer.addView(corePlayerView);
80-
corePlayerView.start("http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4");
80+
corePlayerView.start("https://upload.dongfeng-nissan.com.cn/nissan/video/202204/4cfde6f0-bf80-11ec-95c3-214c38efbbc8.mp4");//天籁宣传片
8181
}
8282
});
8383
}

app/src/main/java/com/android/videoplayer/ui/widget/CorePlayerView.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
*/
2525
public class CorePlayerView extends LinearLayout {
2626

27-
// private static final String URL = "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4";//惊奇队长
28-
private static final String PATH = "http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4";
27+
private static final String PATH = "http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4";//叶问预告片
2928
protected VideoPlayer mVideoPlayer;
3029
private int mCurrentMediaCore;//当前正在使用的解码器类型 0:系统 1:ijk 2:exo
3130
private String mUrl;

app/src/main/java/com/android/videoplayer/ui/widget/ProjectDialog.java

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public void onClick(View v) {
3535
if(null!=mOnMenuActionListener) mOnMenuActionListener.onSelected("https://gitee.com/hty527/iPlayer");
3636
}
3737
});
38+
findViewById(R.id.dialog_close).setOnClickListener(new View.OnClickListener() {
39+
@Override
40+
public void onClick(View v) {
41+
dismiss();
42+
}
43+
});
3844
}
3945

4046
protected void initLayoutPrams(){

app/src/main/java/com/android/videoplayer/utils/DataFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ public void run() {
173173

174174
public List<String> getDataSources(){
175175
List<String> list=new ArrayList<>();
176-
list.add("http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4");
176+
list.add("http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4");
177177
list.add("http://vfx.mtime.cn/Video/2019/03/21/mp4/190321153853126488.mp4");
178-
// list.add("http://vfx.mtime.cn/Video/2019/03/19/mp4/190319222227698228.mp4");
179-
// list.add("http://vfx.mtime.cn/Video/2019/03/19/mp4/190319212559089721.mp4");
178+
list.add("http://vfx.mtime.cn/Video/2019/03/19/mp4/190319222227698228.mp4");
179+
list.add("http://vfx.mtime.cn/Video/2019/03/19/mp4/190319212559089721.mp4");
180180
return list;
181181
}
182182

app/src/main/java/com/android/videoplayer/utils/ScreenUtils.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import android.view.View;
88
import android.view.ViewGroup;
99
import android.view.ViewParent;
10+
1011
import com.android.videoplayer.App;
11-
import java.lang.reflect.Field;
12+
1213
import java.text.DecimalFormat;
1314
import java.text.NumberFormat;
1415

@@ -108,18 +109,17 @@ public Activity getActivity(Context context) {
108109
* @return
109110
*/
110111
public int getStatusBarHeight(Context context) {
112+
int StatusBarHeight = 0;
111113
try {
112-
Class<?> c = Class.forName("com.android.internal.R$dimen");
113-
Object obj = c.newInstance();
114-
Field field = c.getField("status_bar_height");
115-
int x = Integer.parseInt(field.get(obj).toString());
116-
int dimensionPixelSize = context.getResources().getDimensionPixelSize(x);
117-
if(dimensionPixelSize<=0) dimensionPixelSize=ScreenUtils.getInstance().dpToPxInt(25f);
118-
return dimensionPixelSize;
119-
} catch (Exception e) {
114+
int resourceId = context.getApplicationContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
115+
if (resourceId > 0) {
116+
StatusBarHeight = context.getApplicationContext().getResources().getDimensionPixelSize(resourceId);
117+
}
118+
}catch (Exception e){
120119
e.printStackTrace();
120+
StatusBarHeight=dpToPxInt(25f);
121121
}
122-
return ScreenUtils.getInstance().dpToPxInt(25f);
122+
return StatusBarHeight;
123123
}
124124

125125
/**

app/src/main/java/com/android/videoplayer/video/ui/fragment/ListPlayerFragment.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ private void autoPlayerVideo() {
196196
consumption.setCollectionCount(44541);
197197
consumption.setReplyCount(1860223);
198198
consumption.setShareCount(58954);
199-
itemBean.setTitle("漫威惊奇队长");
199+
itemBean.setTitle("惊奇队长2");
200200
itemBean.setConsumption(consumption);
201201
itemBean.setDuration(31);
202202
itemBean.setDate(1657167889000L);
203-
itemBean.setPlayUrl("http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4");
204-
itemBean.setDescription("漫威惊奇队长,是什么让她成为复联最强战力,能力堪比六钻满配灭霸?据说惊奇2已开拍,2023年上映?");
203+
itemBean.setPlayUrl("https://vd3.bdstatic.com/mda-pd736fppd4m1muub/sc/cae_h264/1680924082856978562/mda-pd736fppd4m1muub.mp4");
204+
itemBean.setDescription("惊奇队长2 华丽蜕变!最新官方预告片 2023年11月上映");
205205
mAdapter.addData(0,itemBean);
206206
//开始播放第一个视频
207207
mRecyclerView.postDelayed(new Runnable() {

app/src/main/res/layout/fragment_video_list.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_height="match_parent"
77
android:background="@color/white">
88
<ImageView
9-
android:id="@+id/status_bar"
9+
android:id="@+id/bar_image"
1010
android:layout_width="match_parent"
1111
android:layout_height="1dp"
1212
android:scaleType="centerCrop"/>

app/src/main/res/layout/item_video_list.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919
android:id="@+id/item_title"
2020
android:layout_width="match_parent"
2121
android:layout_height="wrap_content"
22-
android:minLines="2"
22+
android:maxLines="2"
2323
android:textColor="@color/white"
2424
android:textSize="14dp"
2525
android:padding="10dp"
2626
android:includeFontPadding="false"
2727
android:lineSpacingExtra="3dp"
2828
android:gravity="bottom"
2929
android:background="@drawable/fg_video_info"
30-
android:layout_gravity="bottom"/>
30+
android:layout_gravity="bottom"
31+
android:shadowRadius="2"
32+
android:shadowDx="1"
33+
android:shadowDy="1"
34+
android:shadowColor="#80000000"/>
3135
</FrameLayout>
3236
</LinearLayout>

cache/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ task sourcesJar(type: Jar) {
2525
}
2626
dependencies {
2727
implementation fileTree(dir: "libs", include: ["*.jar"])
28-
api 'org.slf4j:slf4j-android:1.7.21'
2928
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.danikula.videocache;
2+
3+
import android.util.Log;
4+
5+
/**
6+
* created by hty
7+
* 2022/12/28
8+
* Desc:
9+
*/
10+
public class CacheLog {
11+
12+
private static final String TAG = "CacheLog";
13+
14+
public static void log(String content){
15+
Log.d(TAG,content);
16+
}
17+
18+
19+
public static void warn(String content) {
20+
warn(content,null);
21+
}
22+
23+
public static void warn(String content, Exception e) {
24+
try {
25+
Log.w(TAG,content+(null!=e?e.getMessage():""));
26+
}catch (Throwable e1){}
27+
}
28+
29+
public static void debug(String content) {
30+
Log.d(TAG,content);
31+
}
32+
33+
public static void error(String error) {
34+
error(error,null);
35+
}
36+
37+
public static void error(String error, Throwable e) {
38+
try {
39+
Log.e(TAG,error+(null!=e?e.getMessage():""));
40+
}catch (Throwable e1){}
41+
}
42+
43+
public static void info(String content) {
44+
Log.i(TAG,content);
45+
}
46+
}

cache/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import com.danikula.videocache.headers.HeaderInjector;
1212
import com.danikula.videocache.sourcestorage.SourceInfoStorage;
1313
import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory;
14-
import org.slf4j.Logger;
15-
import org.slf4j.LoggerFactory;
1614
import java.io.File;
1715
import java.io.IOException;
1816
import java.net.InetAddress;
@@ -49,7 +47,6 @@
4947
*/
5048
public class HttpProxyCacheServer {
5149

52-
private static final Logger LOG = LoggerFactory.getLogger("HttpProxyCacheServer");
5350
private static final String PROXY_HOST = "127.0.0.1";
5451

5552
private final Object clientsLock = new Object();
@@ -77,7 +74,7 @@ private HttpProxyCacheServer(Config config) {
7774
this.waitConnectionThread.start();
7875
startSignal.await(); // freeze thread, wait for server starts
7976
this.pinger = new Pinger(PROXY_HOST, port);
80-
LOG.info("Proxy cache server started. Is it alive? " + isAlive());
77+
CacheLog.info("Proxy cache server started. Is it alive? " + isAlive());
8178
} catch (IOException | InterruptedException e) {
8279
socketProcessor.shutdown();
8380
throw new IllegalStateException("Error starting local proxy server", e);
@@ -124,7 +121,7 @@ public void registerCacheListener(CacheListener cacheListener, String url) {
124121
try {
125122
getClients(url).registerCacheListener(cacheListener);
126123
} catch (ProxyCacheException e) {
127-
LOG.warn("Error registering cache listener", e);
124+
CacheLog.warn("Error registering cache listener", e);
128125
}
129126
}
130127
}
@@ -135,7 +132,7 @@ public void unregisterCacheListener(CacheListener cacheListener, String url) {
135132
try {
136133
getClients(url).unregisterCacheListener(cacheListener);
137134
} catch (ProxyCacheException e) {
138-
LOG.warn("Error registering cache listener", e);
135+
CacheLog.warn("Error registering cache listener", e);
139136
}
140137
}
141138
}
@@ -165,7 +162,7 @@ public boolean isCached(String url) {
165162
}
166163

167164
public void shutdown() {
168-
LOG.info("Shutdown proxy server");
165+
CacheLog.info("Shutdown proxy server");
169166

170167
shutdownClients();
171168

@@ -288,7 +285,7 @@ private void closeSocketInput(Socket socket) {
288285
} catch (SocketException e) {
289286
// There is no way to determine that client closed connection http://stackoverflow.com/a/10241044/999458
290287
// So just to prevent log flooding don't log stacktrace
291-
LOG.debug("Releasing input stream… Socket is closed by client.");
288+
CacheLog.debug("Releasing input stream… Socket is closed by client.");
292289
} catch (Throwable e) {
293290
// onError(new ProxyCacheException("Error closing socket input stream", e));
294291
}
@@ -315,7 +312,7 @@ private void closeSocket(Socket socket) {
315312
}
316313

317314
private void onError(Throwable e) {
318-
LOG.error("HttpProxyCacheServer error", e);
315+
CacheLog.error("HttpProxyCacheServer error", e);
319316
}
320317

321318
private final class WaitRequestsRunnable implements Runnable {

0 commit comments

Comments
 (0)