fix 修复PK过程中挂后台导致摄像头关闭问题
This commit is contained in:
parent
4b3b47b65f
commit
b40abb9bc0
@ -158,7 +158,7 @@ public class LogUtil {
|
|||||||
|
|
||||||
|
|
||||||
public static void shareFile(Context context) {
|
public static void shareFile(Context context) {
|
||||||
try {
|
/* try {
|
||||||
IMLoginModel bean = IMLoginManager.get(context).getUserInfo();
|
IMLoginModel bean = IMLoginManager.get(context).getUserInfo();
|
||||||
boolean isAnchor=false;
|
boolean isAnchor=false;
|
||||||
if(bean!=null){
|
if(bean!=null){
|
||||||
@ -170,7 +170,7 @@ public class LogUtil {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
/* if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
|
/* if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
||||||
return;
|
return;
|
||||||
|
@ -49,17 +49,17 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDownloadApk() {
|
public boolean isDownloadApk() {
|
||||||
if(!CommonAppConfig.IS_PLUGIN_MODEL){
|
if (!CommonAppConfig.IS_PLUGIN_MODEL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk").exists();
|
return new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载主播插件
|
* 加载主播插件
|
||||||
*/
|
*/
|
||||||
public void loadAnchorPlugin(DialogInterface.OnDismissListener dismissListener) {
|
public void loadAnchorPlugin(DialogInterface.OnDismissListener dismissListener) {
|
||||||
if(!CommonAppConfig.IS_PLUGIN_MODEL){
|
if (!CommonAppConfig.IS_PLUGIN_MODEL) {
|
||||||
dismissListener.onDismiss(null);
|
dismissListener.onDismiss(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,7 +73,8 @@ public class PluginManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
File sdk = new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk");
|
File sdk = new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk");
|
||||||
if (!sdk.exists()) {
|
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").exists() || !sdk.exists()) {
|
||||||
|
Log.i(TAG, "loadAnchorPlugin: 插件未下载");
|
||||||
if (StringUtil.isEmpty(anchorPluginDownloadUrl)) {
|
if (StringUtil.isEmpty(anchorPluginDownloadUrl)) {
|
||||||
Log.e(TAG, "主播下载地址为空");
|
Log.e(TAG, "主播下载地址为空");
|
||||||
return;
|
return;
|
||||||
@ -97,8 +98,12 @@ public class PluginManager {
|
|||||||
* @param outDir 解压路径
|
* @param outDir 解压路径
|
||||||
*/
|
*/
|
||||||
private void loadFaceSo(File plugin, String outDir) {
|
private void loadFaceSo(File plugin, String outDir) {
|
||||||
if(!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin"+File.separator+"lib").exists()) {
|
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").exists()) {
|
||||||
unzip(plugin.getAbsolutePath(), outDir, ".so");
|
Log.i(TAG, "loadFaceSo: lib插件未解压");
|
||||||
|
if (unzip(plugin.getAbsolutePath(), outDir, ".so")) {
|
||||||
|
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").mkdirs();
|
||||||
|
Log.i(TAG, "loadFaceSo: lib插件解压");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String[] abis = Build.SUPPORTED_ABIS;
|
String[] abis = Build.SUPPORTED_ABIS;
|
||||||
String abi = Arrays.asList(abis).contains("arm64-v8a") ? "arm64-v8a" : "armeabi-v7a";
|
String abi = Arrays.asList(abis).contains("arm64-v8a") ? "arm64-v8a" : "armeabi-v7a";
|
||||||
@ -108,8 +113,8 @@ public class PluginManager {
|
|||||||
try {
|
try {
|
||||||
Field field = Class.forName("com.faceunity.wrapper.faceunity$LoadConfig").getDeclaredField("sLoadedLibrary");
|
Field field = Class.forName("com.faceunity.wrapper.faceunity$LoadConfig").getDeclaredField("sLoadedLibrary");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(null,true);
|
field.set(null, true);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,8 +126,12 @@ public class PluginManager {
|
|||||||
* @param outDir 解压路径
|
* @param outDir 解压路径
|
||||||
*/
|
*/
|
||||||
private void loadFaceBundle(File plugin, String outDir) {
|
private void loadFaceBundle(File plugin, String outDir) {
|
||||||
if(!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin"+File.separator+"assets").exists()) {
|
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").exists()) {
|
||||||
unzip(plugin.getAbsolutePath(), outDir, ".bundle");
|
Log.i(TAG, "loadFaceBundle: bundle未解压");
|
||||||
|
if (unzip(plugin.getAbsolutePath(), outDir, ".bundle")) {
|
||||||
|
Log.i(TAG, "loadFaceBundle: bundle解压");
|
||||||
|
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").mkdirs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Object BUNDLE_AI_FACE = Class.forName("com.yunbao.faceunity.utils.FURenderer").getField("BUNDLE_AI_FACE").get(null);
|
Object BUNDLE_AI_FACE = Class.forName("com.yunbao.faceunity.utils.FURenderer").getField("BUNDLE_AI_FACE").get(null);
|
||||||
@ -131,6 +140,7 @@ public class PluginManager {
|
|||||||
Class.forName("com.yunbao.faceunity.utils.FaceUnityConfig").getField("BUNDLE_FACE_BEAUTIFICATION").set(null, outDir + File.separator + "assets" + File.separator + BUNDLE_FACE_BEAUTIFICATION);
|
Class.forName("com.yunbao.faceunity.utils.FaceUnityConfig").getField("BUNDLE_FACE_BEAUTIFICATION").set(null, outDir + File.separator + "assets" + File.separator + BUNDLE_FACE_BEAUTIFICATION);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +158,7 @@ public class PluginManager {
|
|||||||
Log.d(TAG, "加载成功 " + dir + File.separator + file);
|
Log.d(TAG, "加载成功 " + dir + File.separator + file);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "不存在 " + dir + File.separator + file);
|
Log.e(TAG, "不存在 " + dir + File.separator + file);
|
||||||
|
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +171,7 @@ public class PluginManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(File file) {
|
public void onSuccess(File file) {
|
||||||
Log.d(TAG, "下载成功 " + file);
|
Log.d(TAG, "下载成功 " + file);
|
||||||
|
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").mkdirs();
|
||||||
loadAnchorPlugin(dismissListener);
|
loadAnchorPlugin(dismissListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +182,7 @@ public class PluginManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
|
downloadAnchorSdk(dismissListener);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -187,13 +199,14 @@ public class PluginManager {
|
|||||||
FileOutputStream out;
|
FileOutputStream out;
|
||||||
byte buffer[] = new byte[1024];
|
byte buffer[] = new byte[1024];
|
||||||
try {
|
try {
|
||||||
|
Log.i(TAG, "unzip: " + outDir);
|
||||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zip));
|
ZipInputStream zis = new ZipInputStream(new FileInputStream(zip));
|
||||||
ZipEntry entry = zis.getNextEntry();
|
ZipEntry entry = zis.getNextEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
String name = entry.getName();
|
String name = entry.getName();
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
File newDir = new File(outDir + entry.getName());
|
File newDir = new File(outDir + entry.getName());
|
||||||
newDir.mkdir();
|
newDir.mkdirs();
|
||||||
} else if (name.endsWith(suffix)) {
|
} else if (name.endsWith(suffix)) {
|
||||||
File outputFile = new File(outDir + File.separator + name);
|
File outputFile = new File(outDir + File.separator + name);
|
||||||
String outputPath = outputFile.getCanonicalPath();
|
String outputPath = outputFile.getCanonicalPath();
|
||||||
@ -206,7 +219,7 @@ public class PluginManager {
|
|||||||
outputFile = new File(outputPath, name);
|
outputFile = new File(outputPath, name);
|
||||||
outputFile.createNewFile();
|
outputFile.createNewFile();
|
||||||
out = new FileOutputStream(outputFile);
|
out = new FileOutputStream(outputFile);
|
||||||
|
Log.i(TAG, "unzip: >>" + outputFile.getAbsolutePath());
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
while ((tmp = zis.read(buffer)) > 0) {
|
while ((tmp = zis.read(buffer)) > 0) {
|
||||||
out.write(buffer, 0, tmp);
|
out.write(buffer, 0, tmp);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 22 KiB |
@ -76,6 +76,7 @@ import cn.rongcloud.rtc.api.RCRTCMixConfig;
|
|||||||
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRoom;
|
import cn.rongcloud.rtc.api.RCRTCRoom;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRoomConfig;
|
import cn.rongcloud.rtc.api.RCRTCRoomConfig;
|
||||||
|
import cn.rongcloud.rtc.api.callback.IRCRTCEngineEventListener;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
|
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
|
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
|
||||||
@ -85,6 +86,7 @@ import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
|
|||||||
import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
|
import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
|
||||||
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
||||||
import cn.rongcloud.rtc.base.RCRTCRoomType;
|
import cn.rongcloud.rtc.base.RCRTCRoomType;
|
||||||
|
import cn.rongcloud.rtc.base.RCRTCVideoEventCode;
|
||||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||||
import cn.rongcloud.rtc.core.CameraVideoCapturer;
|
import cn.rongcloud.rtc.core.CameraVideoCapturer;
|
||||||
import cn.rongcloud.rtc.core.RendererCommon;
|
import cn.rongcloud.rtc.core.RendererCommon;
|
||||||
@ -123,6 +125,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
private ImageView avatarOther;
|
private ImageView avatarOther;
|
||||||
private LinearLayout goto_room_view;
|
private LinearLayout goto_room_view;
|
||||||
private boolean isPk = false;
|
private boolean isPk = false;
|
||||||
|
private boolean isNeedOpenCamera = false;
|
||||||
|
|
||||||
//修改上面主播的头像
|
//修改上面主播的头像
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
@ -175,7 +178,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(RTCErrorCode rtcErrorCode) {
|
public void onFailed(RTCErrorCode rtcErrorCode) {
|
||||||
Log.e("ry", "远端失败" + list.size());
|
Log.e("ry", "远端失败" + list.size() + "|errorCode:" + rtcErrorCode.toString());
|
||||||
ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
|
ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -495,10 +498,10 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
btn_close.setOnClickListener(new View.OnClickListener() {
|
btn_close.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
DialogUitl.showSimpleDialog(mContext,WordUtil.isNewZh()? "是否要斷開連麥?":"Do you want to disconnect Link?", new DialogUitl.SimpleCallback() {
|
DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "是否要斷開連麥?" : "Do you want to disconnect Link?", new DialogUitl.SimpleCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfirmClick(Dialog dialog, String content) {
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
Log.i("PK----->", "updateSub: "+isPk+"|");
|
Log.i("PK----->", "updateSub: " + isPk + "|");
|
||||||
aheadOfScheduleEndPK(mPkUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName(), (String) tv_avatarOther_name.getTag());
|
aheadOfScheduleEndPK(mPkUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName(), (String) tv_avatarOther_name.getTag());
|
||||||
//断开连麦
|
//断开连麦
|
||||||
LiveRyAnchorActivity.isDRPK = 0;
|
LiveRyAnchorActivity.isDRPK = 0;
|
||||||
@ -695,10 +698,34 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
//设置摄像头最大缩放比例
|
//设置摄像头最大缩放比例
|
||||||
boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
|
boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
|
||||||
// ToastUtil.show("设置比例="+zoom);
|
// ToastUtil.show("设置比例="+zoom);
|
||||||
|
Log.i("摄像头", "onSuccess: 打开摄像头");
|
||||||
|
isNeedOpenCamera = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(RTCErrorCode errorCode) {
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
|
Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RCRTCEngine.getInstance().registerEventListener(new IRCRTCEngineEventListener() {
|
||||||
|
@Override
|
||||||
|
public void onKicked(String roomId, RCRTCParamsType.RCRTCKickedReason kickedReason) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(RTCErrorCode errorCode) {
|
||||||
|
super.onError(errorCode);
|
||||||
|
Log.i("摄像头", "onError: 错误码" + errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocalVideoEventNotify(RCRTCVideoEventCode event) {
|
||||||
|
super.onLocalVideoEventNotify(event);
|
||||||
|
Log.i("摄像头", "onLocalVideoEventNotify: 本地视频事件" + event.code);
|
||||||
|
if (event == RCRTCVideoEventCode.END_CAMERA_ERROR_UNKNOWN) {
|
||||||
|
isNeedOpenCamera = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//设置摄像头最大缩放比例
|
//设置摄像头最大缩放比例
|
||||||
@ -918,6 +945,24 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
|
Log.i("摄像头", "onResume: " + isNeedOpenCamera);
|
||||||
|
if(isNeedOpenCamera){
|
||||||
|
RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean data) {
|
||||||
|
//设置摄像头最大缩放比例
|
||||||
|
boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
|
||||||
|
// ToastUtil.show("设置比例="+zoom);
|
||||||
|
Log.i("摄像头", "onSuccess: 打开摄像头");
|
||||||
|
isNeedOpenCamera = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
|
Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1057,6 +1102,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
} else if (event.getType() == LIVE_PK_ING) {
|
} else if (event.getType() == LIVE_PK_ING) {
|
||||||
isPk = true;
|
isPk = true;
|
||||||
}
|
}
|
||||||
Log.i("PK----->", "updateSub: "+isPk+"|"+event.getType());
|
Log.i("PK----->", "updateSub: " + isPk + "|" + event.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2341,11 +2341,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
if (Integer.parseInt(bean.getRedVal()) > 2) {
|
if (Integer.parseInt(bean.getRedVal()) > 2) {
|
||||||
mRedVal.setVisibility(View.VISIBLE);
|
mRedVal.setVisibility(View.VISIBLE);
|
||||||
mRedVal.setText(bean.getRedVal() + "連勝");
|
mRedVal.setText(bean.getRedVal() + (WordUtil.isNewZh()?"連勝":"Win"));
|
||||||
}
|
}
|
||||||
if (Integer.parseInt(bean.getBlueVal()) > 2) {
|
if (Integer.parseInt(bean.getBlueVal()) > 2) {
|
||||||
mBlueVal.setVisibility(View.VISIBLE);
|
mBlueVal.setVisibility(View.VISIBLE);
|
||||||
mBlueVal.setText(bean.getBlueVal() + "連勝");
|
mBlueVal.setText(bean.getBlueVal() + (WordUtil.isNewZh()?"連勝":"Win"));
|
||||||
}
|
}
|
||||||
mPkRankTopIcon.setVisibility(View.VISIBLE);
|
mPkRankTopIcon.setVisibility(View.VISIBLE);
|
||||||
ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon);
|
ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon);
|
||||||
|
Loading…
Reference in New Issue
Block a user