Skip to content

Commit

Permalink
fix release版本详情页无法打开的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
KLOSWC committed Mar 1, 2024
1 parent ab0d441 commit 7cacf3d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ dependencies {
implementation "androidx.media3:media3-exoplayer-rtsp:1.1.1"
implementation "androidx.media3:media3-datasource-rtmp:1.1.1"

implementation "com.aliyun.sdk.android:AliyunPlayer:6.9.0-full"
//implementation 'com.alivc.conan:AlivcConan:0.9.5'
implementation "com.aliyun.sdk.android:AliyunPlayer:5.5.6.0-full"
implementation 'com.alivc.conan:AlivcConan:0.9.5'
implementation 'xyz.doikki.android.dkplayer:dkplayer-ui:3.3.7'
implementation 'xyz.doikki.android.dkplayer:videocache:3.3.7'

Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
-keep public class * extends android.preference.Preference
-keep public class * extends android.view.View

#单独保留该文件 防止低版本由于导包 异常闪退
-keep public class * extends android.app.RemoteAction

# 保留support下的所有类及其内部类
-keep class android.support.** {*;}
# 保留继承的
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/android/app/RemoteAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package android.app;

import android.graphics.drawable.Icon;

/**
* @desc: 低版本APK 打包后不知道为啥一直提示导包失败 就离谱 在这里建立一个空壳
* @author: KLOSW
* @date: 2024-03-01 21:45:41
*/
public class RemoteAction {
public RemoteAction(Icon icon, CharSequence title, CharSequence contentDescription, PendingIntent intent) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.app.RemoteAction;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
Expand Down Expand Up @@ -1126,17 +1125,20 @@ public void onUserLeaveHint() {
} else {
ratio = new Rational(16, 9);
}
List<RemoteAction> actions = new ArrayList<>();
actions.add(generateRemoteAction(android.R.drawable.ic_media_previous, BROADCAST_ACTION_PREV, "Prev", "Play Previous"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_play, BROADCAST_ACTION_PLAYPAUSE, "Play", "Play/Pause"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_next, BROADCAST_ACTION_NEXT, "Next", "Play Next"));
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(ratio)
.setActions(actions).build();
//此处需要大于23 版本才能执行
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
List<android.app.RemoteAction> actions = new ArrayList<>();
actions.add(generateRemoteAction(android.R.drawable.ic_media_previous, BROADCAST_ACTION_PREV, "Prev", "Play Previous"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_play, BROADCAST_ACTION_PLAYPAUSE, "Play", "Play/Pause"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_next, BROADCAST_ACTION_NEXT, "Next", "Play Next"));
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(ratio)
.setActions(actions).build();
enterPictureInPictureMode(params);
}
if (!fullWindows) {
toggleFullPreview();
}
enterPictureInPictureMode(params);
playFragment.getVodController().hideBottom();
playFragment.getPlayer().postDelayed(() -> {
if (!playFragment.getPlayer().isPlaying()) {
Expand All @@ -1147,15 +1149,15 @@ public void onUserLeaveHint() {
}

@RequiresApi(api = Build.VERSION_CODES.O)
private RemoteAction generateRemoteAction(int iconResId, int actionCode, String title, String desc) {
private android.app.RemoteAction generateRemoteAction(int iconResId, int actionCode, String title, String desc) {
final PendingIntent intent =
PendingIntent.getBroadcast(
DetailActivity.this,
actionCode,
new Intent(BROADCAST_ACTION).putExtra("action", actionCode),
0);
final Icon icon = Icon.createWithResource(DetailActivity.this, iconResId);
return (new RemoteAction(icon, title, desc, intent));
return (new android.app.RemoteAction(icon, title, desc, intent));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.app.Activity;
import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.app.RemoteAction;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -1144,14 +1143,16 @@ public void onUserLeaveHint() {
} else {
ratio = new Rational(16, 9);
}
List<RemoteAction> actions = new ArrayList<>();
actions.add(generateRemoteAction(android.R.drawable.ic_media_previous, BROADCAST_ACTION_PREV, "Prev", "Play Previous"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_play, BROADCAST_ACTION_PLAYPAUSE, "Play/Pause", "Play or Pause"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_next, BROADCAST_ACTION_NEXT, "Next", "Play Next"));
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(ratio)
.setActions(actions).build();
enterPictureInPictureMode(params);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O) {
List<android.app.RemoteAction> actions = new ArrayList<>();
actions.add(generateRemoteAction(android.R.drawable.ic_media_previous, BROADCAST_ACTION_PREV, "Prev", "Play Previous"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_play, BROADCAST_ACTION_PLAYPAUSE, "Play/Pause", "Play or Pause"));
actions.add(generateRemoteAction(android.R.drawable.ic_media_next, BROADCAST_ACTION_NEXT, "Next", "Play Next"));
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(ratio)
.setActions(actions).build();
enterPictureInPictureMode(params);
}
mController.hideBottom();
mVideoView.postDelayed(() -> {
if (!mVideoView.isPlaying()) {
Expand Down Expand Up @@ -1208,7 +1209,7 @@ protected void onPause() {
}

@RequiresApi(api = Build.VERSION_CODES.O)
private RemoteAction generateRemoteAction(int iconResId, int actionCode, String title, String desc) {
private android.app.RemoteAction generateRemoteAction(int iconResId, int actionCode, String title, String desc) {

final PendingIntent intent =
PendingIntent.getBroadcast(
Expand All @@ -1217,7 +1218,7 @@ private RemoteAction generateRemoteAction(int iconResId, int actionCode, String
new Intent(BROADCAST_ACTION).putExtra("action", actionCode),
0);
final Icon icon = Icon.createWithResource(PlayActivity.this, iconResId);
return (new RemoteAction(icon, title, desc, intent));
return (new android.app.RemoteAction(icon, title, desc, intent));
}

// takagen99 : PIP fix to close video when close window
Expand Down

0 comments on commit 7cacf3d

Please sign in to comment.