Skip to content

Commit 7729853

Browse files
author
jiajunhui
committed
fix bugs,improve some.
1 parent 9da38f3 commit 7729853

18 files changed

Lines changed: 141 additions & 31 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ demo示例集成了播放控制组件**ControllerCover**、加载中组件**Load
8484
dependencies {
8585
//---------如果仅使用MediaPlayer解码,使用以下依赖。----------
8686
//该依赖仅包含MediaPlayer解码
87-
implementation 'com.kk.taurus.playerbase:playerbase:3.3.4.4'
87+
implementation 'com.kk.taurus.playerbase:playerbase:3.3.5'
8888
8989
9090
//---------如果使用ExoPlayer解码,使用以下依赖。---------
9191
//该依赖包含exoplayer解码和MediaPlayer解码
9292
//注意exoplayer的最小支持SDK版本为16
93-
implementation 'cn.jiajunhui:exoplayer:3344_291_008'
93+
implementation 'cn.jiajunhui:exoplayer:335_291_008'
9494
9595
9696
//---------如果使用ijkPlayer解码,使用以下依赖。---------
9797
//该依赖包含ijkplayer解码和MediaPlayer解码
98-
implementation 'cn.jiajunhui:ijkplayer:3344_088_007'
98+
implementation 'cn.jiajunhui:ijkplayer:335_088_007'
9999
//ijk官方的解码库依赖,较少格式版本且不支持HTTPS。
100100
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
101101
# Other ABIs: optional

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
android:configChanges="keyboardHidden|orientation|screenSize"
4545
android:screenOrientation="portrait"/>
4646

47-
<activity android:name=".HomeActivity" />
47+
<activity
48+
android:name=".HomeActivity"
49+
android:screenOrientation="portrait"/>
4850

4951
<activity
5052
android:name=".ui.BaseVideoViewActivity"
@@ -56,6 +58,7 @@
5658
android:screenOrientation="portrait"/>
5759
<activity
5860
android:name=".ui.window.FloatWindowActivity"
61+
android:launchMode="singleTask"
5962
android:configChanges="keyboardHidden|orientation|screenSize"
6063
android:screenOrientation="portrait"/>
6164
<activity

app/src/main/java/com/kk/taurus/avplayer/cover/GestureCover.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,17 @@ public void run() {
126126
@Override
127127
public String[] filterKeys() {
128128
return new String[]{
129-
DataInter.Key.KEY_COMPLETE_SHOW};
129+
DataInter.Key.KEY_COMPLETE_SHOW,
130+
DataInter.Key.KEY_IS_LANDSCAPE
131+
};
130132
}
131133

132134
@Override
133135
public void onValueUpdate(String key, Object value) {
134-
if(key.equals(DataInter.Key.KEY_COMPLETE_SHOW)){
136+
if(DataInter.Key.KEY_COMPLETE_SHOW.equals(key)){
135137
setGestureEnable(!(boolean) value);
138+
}else if(DataInter.Key.KEY_IS_LANDSCAPE.equals(key)){
139+
notifyWH();
136140
}
137141
}
138142
};
@@ -144,13 +148,17 @@ protected void onCoverAttachedToWindow() {
144148
getView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
145149
@Override
146150
public void onGlobalLayout() {
147-
mWidth = getView().getWidth();
148-
mHeight = getView().getHeight();
151+
notifyWH();
149152
getView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
150153
}
151154
});
152155
}
153156

157+
private void notifyWH() {
158+
mWidth = getView().getWidth();
159+
mHeight = getView().getHeight();
160+
}
161+
154162
@Override
155163
protected void onCoverDetachedToWindow() {
156164
super.onCoverDetachedToWindow();
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.kk.taurus.avplayer.play;
2+
3+
import android.os.Handler;
4+
import android.os.Looper;
5+
import android.text.TextUtils;
6+
7+
import com.kk.taurus.avplayer.utils.DataUtils;
8+
import com.kk.taurus.playerbase.entity.DataSource;
9+
import com.kk.taurus.playerbase.provider.BaseDataProvider;
10+
11+
public class DemoDataProvider extends BaseDataProvider {
12+
13+
private Handler mHandler = new Handler(Looper.getMainLooper());
14+
private Runnable mDelayRunnable;
15+
16+
@Override
17+
public void handleSourceData(final DataSource sourceData) {
18+
if(TextUtils.isEmpty(sourceData.getData())){
19+
cancel();
20+
//模拟请求数据的过程
21+
mHandler.postDelayed(mDelayRunnable = new Runnable() {
22+
@Override
23+
public void run() {
24+
DataSource data = new DataSource(DataUtils.VIDEO_URL_08);
25+
data.setTitle("音乐和艺术如何改变世界");
26+
//success result data
27+
onProviderMediaDataSuccess(data);
28+
//if occur error, you can call this method
29+
//onProviderMediaDataError(bundle);
30+
}
31+
}, 1000);
32+
}else{
33+
onProviderMediaDataSuccess(sourceData);
34+
}
35+
}
36+
37+
@Override
38+
public void cancel() {
39+
if(mDelayRunnable!=null)
40+
mHandler.removeCallbacks(mDelayRunnable);
41+
}
42+
43+
@Override
44+
public void destroy() {
45+
cancel();
46+
}
47+
48+
}

app/src/main/java/com/kk/taurus/avplayer/ui/BaseVideoViewActivity.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class BaseVideoViewActivity extends AppCompatActivity implements
4848

4949
private boolean hasStart;
5050
private RecyclerView mRecycler;
51+
private SettingAdapter mAdapter;
5152

5253
@Override
5354
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -77,7 +78,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7778

7879
private void initPlay(){
7980
if(!hasStart){
80-
DataSource dataSource = new DataSource(DataUtils.VIDEO_URL_08);
81+
DataSource dataSource = new DataSource(DataUtils.VIDEO_URL_09);
8182
dataSource.setTitle("音乐和艺术如何改变世界");
8283
mVideoView.setDataSource(dataSource);
8384
mVideoView.start();
@@ -89,10 +90,12 @@ private void initPlay(){
8990
public void onPlayerEvent(int eventCode, Bundle bundle) {
9091
switch (eventCode){
9192
case OnPlayerEventListener.PLAYER_EVENT_ON_VIDEO_RENDER_START:
92-
mRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
93-
SettingAdapter mAdapter = new SettingAdapter(this, SettingItem.initSettingList());
94-
mAdapter.setOnItemClickListener(this);
95-
mRecycler.setAdapter(mAdapter);
93+
if(mAdapter==null){
94+
mRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
95+
mAdapter = new SettingAdapter(this, SettingItem.initSettingList());
96+
mAdapter.setOnItemClickListener(this);
97+
mRecycler.setAdapter(mAdapter);
98+
}
9699
break;
97100
}
98101
}
@@ -132,7 +135,7 @@ public void requestRetry(BaseVideoView videoView, Bundle bundle) {
132135
};
133136

134137
private void replay(){
135-
mVideoView.setDataSource(new DataSource(DataUtils.VIDEO_URL_01));
138+
mVideoView.setDataSource(new DataSource(DataUtils.VIDEO_URL_09));
136139
mVideoView.start();
137140
}
138141

app/src/main/java/com/kk/taurus/avplayer/ui/window/FloatWindowActivity.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,21 @@ public void onConfigurationChanged(Configuration newConfig) {
166166
mReceiverGroup.getGroupValue().putBoolean(DataInter.Key.KEY_IS_LANDSCAPE, isLandScape);
167167
}
168168

169+
@Override
170+
protected void onNewIntent(Intent intent) {
171+
super.onNewIntent(intent);
172+
enterFullScreen();
173+
}
174+
169175
private void enterFullScreen(){
170-
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
171-
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
172-
if(mWhoIntentFullScreen==WINDOW_INTENT_FULL_SCREEN){
173-
normalPlay();
176+
if(PUtil.isTopActivity(this)){
177+
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
178+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
179+
if(mWhoIntentFullScreen==WINDOW_INTENT_FULL_SCREEN){
180+
normalPlay();
181+
}
182+
}else{
183+
startActivity(new Intent(getApplicationContext(), FloatWindowActivity.class));
174184
}
175185
}
176186

app/src/main/java/com/kk/taurus/avplayer/ui/window/WindowVideoViewActivity.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
import com.kk.taurus.avplayer.R;
1414
import com.kk.taurus.avplayer.cover.CloseCover;
1515
import com.kk.taurus.avplayer.play.DataInter;
16+
import com.kk.taurus.avplayer.play.DemoDataProvider;
1617
import com.kk.taurus.avplayer.play.ReceiverGroupManager;
1718
import com.kk.taurus.avplayer.utils.PUtil;
1819
import com.kk.taurus.avplayer.utils.WindowPermissionCheck;
1920
import com.kk.taurus.playerbase.assist.OnVideoViewEventHandler;
2021
import com.kk.taurus.playerbase.entity.DataSource;
2122
import com.kk.taurus.playerbase.player.IPlayer;
23+
import com.kk.taurus.playerbase.provider.IDataProvider;
2224
import com.kk.taurus.playerbase.receiver.ReceiverGroup;
2325
import com.kk.taurus.playerbase.widget.BaseVideoView;
2426
import com.kk.taurus.playerbase.window.FloatWindowParams;
@@ -32,6 +34,8 @@ public class WindowVideoViewActivity extends AppCompatActivity {
3234

3335
DataSource mDataSource;
3436

37+
IDataProvider mDataProvider;
38+
3539
@Override
3640
protected void onCreate(@Nullable Bundle savedInstanceState) {
3741
super.onCreate(savedInstanceState);
@@ -72,8 +76,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7276
mWindowVideoView.setReceiverGroup(receiverGroup);
7377

7478
mDataSource = new DataSource();
75-
mDataSource.setData("https://mov.bn.netease.com/open-movie/nos/mp4/2018/01/12/SD70VQJ74_sd.mp4");
76-
mDataSource.setTitle("不想从被子里出来");
79+
mDataSource.setId(1234567);
80+
mWindowVideoView.setDataProvider(mDataProvider = new DemoDataProvider());
81+
mWindowVideoView.setDataSource(mDataSource);
7782

7883
}
7984

@@ -137,15 +142,14 @@ protected void onResume() {
137142
return;
138143
if(mWindowVideoView.isInPlaybackState())
139144
mWindowVideoView.resume();
140-
else
141-
mWindowVideoView.rePlay(0);
142145
}
143146

144147
@Override
145148
protected void onDestroy() {
146149
super.onDestroy();
147150
mWindowVideoView.close();
148151
mWindowVideoView.stopPlayback();
152+
mDataProvider.destroy();
149153
}
150154
}
151155

app/src/main/java/com/kk/taurus/avplayer/utils/DataUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class DataUtils {
2020
public static final String VIDEO_URL_06 = "http://jiajunhui.cn/video/big_buck_bunny.mp4";
2121
public static final String VIDEO_URL_07 = "http://jiajunhui.cn/video/trailer.mp4";
2222
public static final String VIDEO_URL_08 = "https://mov.bn.netease.com/open-movie/nos/mp4/2017/12/04/SD3SUEFFQ_hd.mp4";
23+
public static final String VIDEO_URL_09 = "https://mov.bn.netease.com/open-movie/nos/mp4/2017/05/31/SCKR8V6E9_hd.mp4";
2324

2425
public static String[] urls = new String[]{
2526
VIDEO_URL_01,

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.2'
10+
classpath 'com.android.tools.build:gradle:3.3.2'
1111
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1212
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
1313

exoplayer/bintray.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.github.dcendents.android-maven'
22
apply plugin: 'com.jfrog.bintray'
33

44
// 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
5-
version = "3344_291_008"
5+
version = "335_291_008"
66

77
def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页
88
def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url

0 commit comments

Comments
 (0)