diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1dd881b18..f6027866f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -47,8 +47,6 @@
-
diff --git a/common/build.gradle b/common/build.gradle
index 40ed75fdc..6ae3648f4 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -154,7 +154,7 @@ dependencies {
//此处以集成 5.1.2 版本为例
api 'cn.rongcloud.sdk:im_lib:5.2.0.2'
- api 'com.facebook.android:facebook-login:6.5.0'
+ api 'com.facebook.android:facebook-login:8.2.0'
api 'com.facebook.android:facebook-android-sdk:[5,6)'
api('com.twitter.sdk.android:twitter-core:3.1.1@aar') {
diff --git a/live/build.gradle b/live/build.gradle
index d3a86cef2..c9272badb 100644
--- a/live/build.gradle
+++ b/live/build.gradle
@@ -1 +1 @@
-apply plugin: 'com.android.library'
apply plugin: 'img-optimizer'
apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
packagingOptions {
pickFirst "lib/armeabi/libyuvutils.so"
pickFirst "lib/arm64-v8a/libyuvutils.so"
pickFirst "lib/armeabi-v7a/libyuvutils.so"
pickFirst "lib/armeabi/libyuvtools.so"
pickFirst "lib/arm64-v8a/libyuvtools.so"
pickFirst "lib/armeabi-v7a/libyuvtools.so"
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
exclude "lib/arm64-v8a/libmmcv_api_express.so"
exclude "lib/arm64-v8a/libMediaEncoder.so"
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
exclude "lib/arm64-v8a/libmediadecoder.so"
exclude "lib/arm64-v8a/libMediaMuxer.so"
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
exclude "lib/arm64-v8a/libMediaUtils.so"
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
}
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
kotlinOptions {
allWarningsAsErrors = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs 'libs', '../libs'
}
mavenCentral()
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
//socket.io
implementation('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
//common
implementation project(path: ':common')
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
//萌颜
implementation project(path: ':beauty')
//工具
api rootProject.ext.dependencies["blank-utilcode"]
implementation 'com.eightbitlab:blurview:1.6.6'
implementation files('libs/beautysdk-202202241203.aar')
implementation 'com.google.code.gson:gson:2.8.6'
implementation "com.getkeepsafe.relinker:relinker:1.4.4"
}
\ No newline at end of file
+apply plugin: 'com.android.library'
apply plugin: 'img-optimizer'
apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
packagingOptions {
pickFirst "lib/armeabi/libyuvutils.so"
pickFirst "lib/arm64-v8a/libyuvutils.so"
pickFirst "lib/armeabi-v7a/libyuvutils.so"
pickFirst "lib/armeabi/libyuvtools.so"
pickFirst "lib/arm64-v8a/libyuvtools.so"
pickFirst "lib/armeabi-v7a/libyuvtools.so"
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
exclude "lib/arm64-v8a/libmmcv_api_express.so"
exclude "lib/arm64-v8a/libMediaEncoder.so"
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
exclude "lib/arm64-v8a/libmediadecoder.so"
exclude "lib/arm64-v8a/libMediaMuxer.so"
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
exclude "lib/arm64-v8a/libMediaUtils.so"
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
}
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
kotlinOptions {
allWarningsAsErrors = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs 'libs', '../libs'
}
mavenCentral()
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
//socket.io
implementation('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
//common
implementation project(path: ':common')
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
//工具
api rootProject.ext.dependencies["blank-utilcode"]
implementation 'com.eightbitlab:blurview:1.6.6'
implementation files('libs/beautysdk-202202241203.aar')
implementation 'com.google.code.gson:gson:2.8.6'
implementation "com.getkeepsafe.relinker:relinker:1.4.4"
}
\ No newline at end of file
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
index 23d405470..4c776fdf7 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
@@ -20,7 +20,6 @@ import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.tencent.trtc.TRTCCloudDef;
-import com.yunbao.beauty.interfaces.BeautyViewHolder;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@@ -100,7 +99,6 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
private ViewGroup mContainerWrap;
private AbsLivePushViewHolder mLivePushViewHolder;
public static LiveReadyViewHolder mLiveReadyViewHolder;
- private BeautyViewHolder mLiveBeautyViewHolder;
private LiveAnchorViewHolder mLiveAnchorViewHolder;
private LiveMusicViewHolder mLiveMusicViewHolder;
private boolean mStartPreview;//是否开始预览
@@ -717,10 +715,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
LivePushTxViewHolder.mTRTCCloud.stopLocalPreview();
}
- if (mLiveBeautyViewHolder != null && mLiveBeautyViewHolder.isShowed()) {
- mLiveBeautyViewHolder.hide();
- return;
- }
+
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
}
@@ -782,10 +777,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom();
}
- if (mLiveBeautyViewHolder != null && mLiveBeautyViewHolder.isShowed()) {
- mLiveBeautyViewHolder.hide();
- return;
- }
+
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
}
@@ -849,9 +841,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.release();
}
- if (mLiveBeautyViewHolder != null) {
- mLiveBeautyViewHolder.release();
- }
+
// if (mGamePresenter != null) {
// mGamePresenter.release();
// }
@@ -859,8 +849,6 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
mLiveReadyViewHolder = null;
mLivePushViewHolder = null;
mLiveLinkMicPresenter = null;
- mLiveBeautyViewHolder = null;
-// mGamePresenter = null;
super.release();
}
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java
index 5b01ef5ef..8c3dba5a2 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java
@@ -19,7 +19,6 @@ import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.opensource.svgaplayer.SVGAImageView;
import com.tencent.trtc.TRTCCloudDef;
-import com.yunbao.beauty.interfaces.BeautyViewHolder;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@@ -120,7 +119,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
private ViewGroup mContainerWrap;
public static AbsRyLivePushViewHolder mLivePushViewHolder;
public static LiveReadyRyViewHolder mLiveReadyViewHolder;
- private BeautyViewHolder mLiveBeautyViewHolder;
public static LiveRyAnchorViewHolder mLiveAnchorViewHolder;
private LiveMusicViewHolder mLiveMusicViewHolder;
private boolean mStartPreview;//是否开始预览
@@ -796,10 +794,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
});
- if (mLiveBeautyViewHolder != null && mLiveBeautyViewHolder.isShowed()) {
- mLiveBeautyViewHolder.hide();
- return;
- }
+
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
}
@@ -866,10 +861,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveAnchorViewHolder.release();
mLiveAnchorViewHolder = null;
}
- if (mLiveBeautyViewHolder != null && mLiveBeautyViewHolder.isShowed()) {
- mLiveBeautyViewHolder.hide();
- return;
- }
+
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
}
@@ -936,9 +928,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.release();
}
- if (mLiveBeautyViewHolder != null) {
- mLiveBeautyViewHolder.release();
- }
+
// if (mGamePresenter != null) {
// mGamePresenter.release();
// }
@@ -946,7 +936,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveReadyViewHolder = null;
mLivePushViewHolder = null;
mLiveLinkMicPresenter = null;
- mLiveBeautyViewHolder = null;
// mGamePresenter = null;
super.release();
}
diff --git a/live/src/main/java/com/yunbao/live/interfaces/ILivePushViewHolder.java b/live/src/main/java/com/yunbao/live/interfaces/ILivePushViewHolder.java
index bc964473e..64c314043 100644
--- a/live/src/main/java/com/yunbao/live/interfaces/ILivePushViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/interfaces/ILivePushViewHolder.java
@@ -1,6 +1,5 @@
package com.yunbao.live.interfaces;
-import com.yunbao.beauty.interfaces.BeautyEffectListener;
/**
* Created by cxf on 2018/12/22.
@@ -50,8 +49,5 @@ public interface ILivePushViewHolder extends ILiveLinkMicViewHolder {
*/
void stopBgm();
- /**
- * 获取美颜效果监听
- */
- BeautyEffectListener getEffectListener();
+
}
diff --git a/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java b/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java
index 98c8fed7b..5a5bee746 100644
--- a/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java
@@ -16,13 +16,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.yunbao.beauty.interfaces.Beauty360EffectListener;
-import com.yunbao.beauty.interfaces.BeautyEffectListener;
-import com.yunbao.beauty.interfaces.DefaultBeautyEffectListener;
-import com.yunbao.beauty.interfaces.TiBeautyEffectListener;
-import com.yunbao.beauty.views.Beauty360ViewHolder;
-import com.yunbao.beauty.views.DefaultBeautyViewHolder;
-import com.yunbao.beauty.views.TiBeautyViewHolder;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.utils.DpUtil;
@@ -34,11 +27,6 @@ import com.yunbao.live.interfaces.ILivePushViewHolder;
import com.yunbao.live.interfaces.LivePushListener;
import cn.qqtheme.framework.util.ScreenUtils;
-import cn.tillusory.sdk.TiSDKManager;
-import cn.tillusory.sdk.TiSDKManagerBuilder;
-import cn.tillusory.sdk.bean.TiDistortionEnum;
-import cn.tillusory.sdk.bean.TiFilterEnum;
-import cn.tillusory.sdk.bean.TiRockEnum;
/**
* Created by cxf on 2018/12/22.
@@ -61,8 +49,7 @@ public abstract class AbsLivePushViewHolder extends AbsViewHolder implements ILi
public static ImageView leave;
public static TXCloudVideoView mPreView1;
protected boolean mOpenCamera;//是否选择了相机
- protected BeautyEffectListener mEffectListener;//萌颜的效果监听
- protected TiSDKManager mTiSDKManager;//萌颜效果控制器
+
//倒计时
protected TextView mCountDownText;
@@ -88,133 +75,17 @@ public abstract class AbsLivePushViewHolder extends AbsViewHolder implements ILi
// if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
if ("2".equals(mBeautySdkType)) {
- initBeauty();
- mEffectListener = new TiBeautyEffectListener() {
- @Override
- public void onFilterChanged(TiFilterEnum tiFilterEnum) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setFilterEnum(tiFilterEnum);
- }
- }
- @Override
- public void onMeiBaiChanged(int progress) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setSkinWhitening(progress);
- }
- }
- @Override
- public void onMoPiChanged(int progress) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setSkinBlemishRemoval(progress);
- }
- }
-
- @Override
- public void onBaoHeChanged(int progress) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setSkinSaturation(progress);
- }
- }
-
- @Override
- public void onFengNenChanged(int progress) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setSkinTenderness(progress);
- }
- }
-
- @Override
- public void onBigEyeChanged(int progress) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setEyeMagnifying(progress);
- }
- }
-
- @Override
- public void onFaceChanged(int progress) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setChinSlimming(progress);
- }
- }
- @Override
- public void onFaceNarrowing(int progress){
- if (mTiSDKManager != null) {
- mTiSDKManager.setFaceNarrowing(progress);
- }
- }
- @Override
- public void onTieZhiChanged(String tieZhiName) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setSticker(tieZhiName);
- }
- }
-
- @Override
- public void onHaHaChanged(TiDistortionEnum tiDistortionEnum) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setDistortionEnum(tiDistortionEnum);
- }
- }
-
- @Override
- public void onRockChanged(TiRockEnum tiRockEnum) {
- if (mTiSDKManager != null) {
- mTiSDKManager.setRockEnum(tiRockEnum);
- }
- }
- };
}else if ("3".equals(mBeautySdkType)){
- mEffectListener = getBeauty360EffectListener();
- //todo 重设右边小窗口高度
- int height= ScreenUtils.heightPixels(mContext);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
- mPkContainer.getLayoutParams();
- params.height = height / 2 + DpUtil.dp2px(20);//布局文件中底部已经空出20
- mPkContainer.setLayoutParams(params);
}
else {
- mEffectListener = getDefaultEffectListener();
}
}
- /**
- * 初始化萌颜
- */
- private void initBeauty() {
- try {
- mTiSDKManager = new TiSDKManagerBuilder().build();
- mTiSDKManager.setBeautyEnable(true);
- mTiSDKManager.setFaceTrimEnable(true);
- ConfigBean configBean = CommonAppConfig.getInstance().getConfig();
- if (configBean != null) {
- mTiSDKManager.setSkinWhitening(configBean.getBeautyMeiBai());//美白
- mTiSDKManager.setSkinBlemishRemoval(configBean.getBeautyMoPi());//磨皮
- mTiSDKManager.setSkinSaturation(configBean.getBeautyBaoHe());//饱和
- mTiSDKManager.setSkinTenderness(configBean.getBeautyFenNen());//粉嫩
- mTiSDKManager.setEyeMagnifying(configBean.getBeautyBigEye());//大眼
- mTiSDKManager.setChinSlimming(configBean.getBeautyFace());//瘦脸
- } else {
- mTiSDKManager.setSkinWhitening(0);//美白
- mTiSDKManager.setSkinBlemishRemoval(0);//磨皮
- mTiSDKManager.setSkinSaturation(0);//饱和
- mTiSDKManager.setSkinTenderness(0);//粉嫩
- mTiSDKManager.setEyeMagnifying(0);//大眼
- mTiSDKManager.setChinSlimming(0);//瘦脸
- }
- mTiSDKManager.setSticker("");
- mTiSDKManager.setFilterEnum(TiFilterEnum.NO_FILTER);
- } catch (Exception e) {
- mTiSDKManager = null;
- ToastUtil.show(R.string.beauty_init_error);
- }
- }
-
-
/**
* 开播的时候 3 2 1倒计时
*/
@@ -283,16 +154,10 @@ public abstract class AbsLivePushViewHolder extends AbsViewHolder implements ILi
mLivePushListener = livePushListener;
}
- @Override
- public BeautyEffectListener getEffectListener() {
- return mEffectListener;
- }
+
protected abstract void onCameraRestart();
- protected abstract DefaultBeautyEffectListener getDefaultEffectListener();
- protected abstract Beauty360EffectListener getBeauty360EffectListener();
-
@Override
public void release() {
@@ -312,9 +177,7 @@ public abstract class AbsLivePushViewHolder extends AbsViewHolder implements ILi
@Override
public void onDestroy() {
- if (mTiSDKManager != null) {
- mTiSDKManager.destroy();
- }
+
L.e(TAG, "LifeCycle------>onDestroy");
}
diff --git a/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java b/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java
index c01a12c7e..b0e368932 100644
--- a/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java
@@ -11,10 +11,7 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
-import com.yunbao.beauty.interfaces.Beauty360EffectListener;
-import com.yunbao.beauty.interfaces.BeautyEffectListener;
-import com.yunbao.beauty.interfaces.DefaultBeautyEffectListener;
-import com.yunbao.beauty.interfaces.TiBeautyEffectListener;
+
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.utils.DpUtil;
@@ -26,11 +23,7 @@ import com.yunbao.live.interfaces.ILivePushViewHolder;
import com.yunbao.live.interfaces.LivePushListener;
import cn.qqtheme.framework.util.ScreenUtils;
-import cn.tillusory.sdk.TiSDKManager;
-import cn.tillusory.sdk.TiSDKManagerBuilder;
-import cn.tillusory.sdk.bean.TiDistortionEnum;
-import cn.tillusory.sdk.bean.TiFilterEnum;
-import cn.tillusory.sdk.bean.TiRockEnum;
+
public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushViewHolder {
@@ -171,10 +164,6 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
}
- @Override
- public BeautyEffectListener getEffectListener() {
- return null;
- }
@Override
public void setLivePushListener(LivePushListener livePushListener) {
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java
index 92e0940c6..5113d0f4e 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java
@@ -27,8 +27,6 @@ import com.tencent.rtmp.ui.TXCloudVideoView;
import com.tencent.trtc.TRTCCloud;
import com.tencent.trtc.TRTCCloudDef;
import com.tencent.trtc.TRTCCloudListener;
-import com.yunbao.beauty.interfaces.Beauty360EffectListener;
-import com.yunbao.beauty.interfaces.DefaultBeautyEffectListener;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@@ -525,15 +523,6 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
// }
}
- @Override
- protected DefaultBeautyEffectListener getDefaultEffectListener() {
- return null;
- }
-
- @Override
- protected Beauty360EffectListener getBeauty360EffectListener() {
- return null;
- }
@Override
public void release() {
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java
index a004c1842..ee6488832 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java
@@ -26,9 +26,6 @@ import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePushConfig;
import com.tencent.rtmp.TXLivePusher;
import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.yunbao.beauty.bean.FilterBean;
-import com.yunbao.beauty.interfaces.Beauty360EffectListener;
-import com.yunbao.beauty.interfaces.DefaultBeautyEffectListener;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@@ -47,10 +44,7 @@ import java.io.File;
import cn.qqtheme.framework.util.FileUtils;
import cn.qqtheme.framework.util.ScreenUtils;
-import cn.tillusory.sdk.bean.TiDistortionEnum;
-import cn.tillusory.sdk.bean.TiRockEnum;
-import cn.tillusory.sdk.bean.TiRotation;
-import cn.tillusory.sdk.common.TiUtils;
+
//import static cn.jpush.im.android.api.jmrtc.JMRTCInternalUse.getApplicationContext;
@@ -156,9 +150,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
mLivePusher.setVideoProcessListener(new TXLivePusher.VideoCustomProcessListener() {
@Override
public int onTextureCustomProcess(int i, int i1, int i2) {
- if (mTiSDKManager != null) {
- return mTiSDKManager.renderTexture2D(i, i1, i2, TiRotation.CLOCKWISE_ROTATION_0, false);
- }
+
return 0;
}
@Override
@@ -216,7 +208,6 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
//解压到贴纸目录
File targetDir = new File(CommonAppConfig.VIDEO_TIE_ZHI_PATH+CommonAppConfig.TIEZHI_360_NAME);
try {
- TiUtils.unzip(file, targetDir);
}catch (Exception e){
// ToastUtil.show(WordUtil.getString(com.yunbao.beauty.R.string.tiezhi_unzip_failed));
}
@@ -262,153 +253,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
}
- // 360美颜回调
- @Override
- protected Beauty360EffectListener getBeauty360EffectListener() {
- return new Beauty360EffectListener() {
- @Override
- public void onFilterChanged(String filtertype) {
- //滤镜类型
-// if ("none".equals(filtertype)){
-// mPreviewUtils.SetColorFilterStrength(0);
-// }
-// else {
-// mPreviewUtils.SetColorFilterByName(filtertype);
-// }
- }
- @Override
- public void onFilterStrength(int filterValue) {
- //滤镜强度
-// mPreviewUtils.SetColorFilterStrength(filterValue);
- }
-
- @Override
- public void onMeiBaiChanged(int progress) {
- mWhitenValue = progress / 100f;
-// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
-
- }
-
- @Override
- public void onSkinsoftStrengthChanged(int progress) {
- mSoftenValue = progress;
-// mPreviewUtils.SetSkinSoftenStrength(mSoftenValue);
- }
-
- @Override
- public void onHongRunChanged(int progress) {
- mReddenValue = progress / 100f;
-// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
- }
-
- @Override
- public void onFengNenChanged(int progress) {
- mPinkValue = progress / 100f;
-// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
- }
-
- @Override
- public void onBigEyeChanged(int progress) {
- mBigEyeStrength=progress;
-// mPreviewUtils.setFaceShapingParam(mBigEyeStrength,mThinFaceStrength);
- }
-
- @Override
- public void onFaceChanged(int progress) {
- mThinFaceStrength=progress;
-// mPreviewUtils.setFaceShapingParam(mBigEyeStrength,mThinFaceStrength);
- }
-
- @Override
- public void onTieZhiChanged(String tieZhiName) {
- //切换贴纸
- if ("无".equals(tieZhiName)) {
-// mPreviewUtils.removeSticker();
- }
- else {
-// mPreviewUtils.setSticker(CommonAppConfig.VIDEO_TIE_ZHI_PATH+CommonAppConfig.TIEZHI_360_NAME
-// +File.separator + "StickerResource_20170502"+File.separator+tieZhiName);
- }
- }
-
- @Override
- public void onHaHaChanged(TiDistortionEnum tiDistortionEnum) {
-
- }
-
- @Override
- public void onRockChanged(TiRockEnum tiRockEnum) {
-
- }
-
- @Override
- public void onFaceNarrowing(int progress) {
-
- }
- };
- }
-
- @Override
- public DefaultBeautyEffectListener getDefaultEffectListener() {
- return new DefaultBeautyEffectListener() {
-
- @Override
- public void onFilterChanged(FilterBean bean) {
- if (bean == null || mLivePusher == null) {
- return;
- }
- if (mFilterBmp != null) {
- mFilterBmp.recycle();
- }
- int filterSrc = bean.getFilterSrc();
- if (filterSrc != 0) {
- Bitmap bitmap = BitmapUtil.getInstance().decodeBitmap(filterSrc);
- if (bitmap != null) {
- mFilterBmp = bitmap;
- mLivePusher.setFilter(bitmap);
- } else {
- mLivePusher.setFilter(null);
- }
- } else {
- mLivePusher.setFilter(null);
- }
- }
-
- @Override
- public void onMeiBaiChanged(int progress) {
- if (mLivePusher != null) {
- int v = progress / 10;
- if (mMeiBaiVal != v) {
- mMeiBaiVal = v;
- mLivePusher.setBeautyFilter(0, mMeiBaiVal, mMoPiVal, mHongRunVal);
- }
- }
- }
-
- @Override
- public void onMoPiChanged(int progress) {
- if (mLivePusher != null) {
- int v = progress / 10;
- if (mMoPiVal != v) {
- mMoPiVal = v;
- mLivePusher.setBeautyFilter(0, mMeiBaiVal, mMoPiVal, mHongRunVal);
- }
- }
- }
-
- @Override
- public void onHongRunChanged(int progress) {
- if (mLivePusher != null) {
- int v = progress / 10;
- if (mHongRunVal != v) {
- mHongRunVal = v;
- mLivePusher.setBeautyFilter(0, mMeiBaiVal, mMoPiVal, mHongRunVal);
- }
- }
- }
- };
- }
@Override
public void changeToLeft() {
diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
index 551b90b8f..770c24207 100644
--- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
@@ -89,7 +89,6 @@ import com.yunbao.main.views.MainHomeShopViewHolder;
import com.yunbao.main.views.MainHomeVideoViewHolder;
import com.yunbao.main.views.MainHomeViewHolder;
import com.yunbao.main.views.MainMeViewHolder;
-import com.yunbao.video.activity.VideoRecord360BeautyActivity;
import com.yunbao.video.utils.VideoStorge;
import org.greenrobot.eventbus.EventBus;
@@ -710,21 +709,16 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
public void run() {
String mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType();
if ("2".equals(mBeautySdkType)) {
-// startActivity(new Intent(mContext, VideoRecordActivity.class));
Constants.myIntoIndex = 2;
Intent intent = new Intent(mContext, MyWebViewActivity.class);
intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/release" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isRelease=1");
startActivity(intent);
- } else if ("3".equals(mBeautySdkType)) {
- startActivity(new Intent(mContext, VideoRecord360BeautyActivity.class));
} else {
-// startActivity(new Intent(mContext, VideoRecordActivity.class));
Constants.myIntoIndex = 2;
Intent intent = new Intent(mContext, MyWebViewActivity.class);
intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/release" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isRelease=1");
startActivity(intent);
}
-// startActivity(new Intent(mContext, VideoRecordActivity.class));
}
};
diff --git a/settings.gradle b/settings.gradle
index 9c4bdc535..c1d4b9e9b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':beauty', ':video', ':common', ':main', ':baidu', ':live', ':lib_country_code'
+include ':app', ':video', ':common', ':main', ':baidu', ':live', ':lib_country_code'
diff --git a/video/build.gradle b/video/build.gradle
index f0a857afb..7368bedbd 100644
--- a/video/build.gradle
+++ b/video/build.gradle
@@ -61,9 +61,7 @@ dependencies {
implementation rootProject.ext.dependencies["recyclerview-androidx"]
//common
implementation project(path: ':common')
- //萌颜
- implementation project(path: ':beauty')
- //萌颜
+
implementation project(path: ':live')
}
diff --git a/video/src/main/AndroidManifest.xml b/video/src/main/AndroidManifest.xml
index b6407cedd..c934b76ad 100644
--- a/video/src/main/AndroidManifest.xml
+++ b/video/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
-
-
+
-
diff --git a/video/src/main/java/com/yunbao/video/activity/VideoRecord360BeautyActivity.java b/video/src/main/java/com/yunbao/video/activity/VideoRecord360BeautyActivity.java
deleted file mode 100644
index a597b1d44..000000000
--- a/video/src/main/java/com/yunbao/video/activity/VideoRecord360BeautyActivity.java
+++ /dev/null
@@ -1,1193 +0,0 @@
-package com.yunbao.video.activity;
-
-import android.animation.ValueAnimator;
-import android.app.Dialog;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import androidx.core.content.ContextCompat;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.TextView;
-
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.tencent.ugc.TXRecordCommon;
-import com.tencent.ugc.TXUGCPartsManager;
-import com.tencent.ugc.TXUGCRecord;
-import com.yunbao.beauty.bean.FilterBean;
-import com.yunbao.beauty.interfaces.Beauty360EffectListener;
-import com.yunbao.beauty.interfaces.BeautyViewHolder;
-import com.yunbao.beauty.interfaces.DefaultBeautyEffectListener;
-import com.yunbao.beauty.interfaces.TiBeautyEffectListener;
-import com.yunbao.beauty.views.DefaultBeautyViewHolder;
-import com.yunbao.beauty.views.TiBeautyViewHolder;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.CommonAppContext;
-import com.yunbao.common.Constants;
-import com.yunbao.common.activity.AbsActivity;
-import com.yunbao.common.bean.ConfigBean;
-import com.yunbao.common.custom.DrawableRadioButton2;
-import com.yunbao.common.utils.BitmapUtil;
-import com.yunbao.common.utils.DialogUitl;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.StringUtil;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.utils.WordUtil;
-import com.yunbao.video.R;
-import com.yunbao.video.bean.MusicBean;
-import com.yunbao.video.custom.RecordProgressView;
-import com.yunbao.video.custom.VideoRecordBtnView;
-import com.yunbao.video.views.VideoMusicViewHolder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import cn.tillusory.sdk.TiSDKManager;
-import cn.tillusory.sdk.TiSDKManagerBuilder;
-import cn.tillusory.sdk.bean.TiDistortionEnum;
-import cn.tillusory.sdk.bean.TiFilterEnum;
-import cn.tillusory.sdk.bean.TiRockEnum;
-import cn.tillusory.sdk.bean.TiRotation;
-
-/**
- * Created by cxf on 2018/12/5.
- * 视频录制(360美颜)
- */
-
-public class VideoRecord360BeautyActivity extends AbsActivity implements
- TXRecordCommon.ITXVideoRecordListener, //视频录制进度回调
- TiBeautyEffectListener, //设置美颜数值回调
- TXUGCRecord.VideoCustomProcessListener //视频录制中自定义预处理(添加美颜回调)
-{
-
- private static final String TAG = "VideoRecordActivity";
- private static final int MIN_DURATION = 5000;//最小录制时间5s
- private static final int MAX_DURATION = 15000;//最大录制时间15s
- //按钮动画相关
- private VideoRecordBtnView mVideoRecordBtnView;
- private View mRecordView;
- private ValueAnimator mRecordBtnAnimator;//录制开始后,录制按钮动画
- private Drawable mRecordDrawable;
- private Drawable mUnRecordDrawable;
-
- /****************************/
- private boolean mRecordStarted;//是否开始了录制(true 已开始 false 未开始)
- private boolean mRecordStoped;//是否结束了录制
- private boolean mRecording;//是否在录制中((true 录制中 false 暂停中)
- private ViewGroup mRoot;
- private TXCloudVideoView mVideoView;//预览控件
- private RecordProgressView mRecordProgressView;//录制进度条
- private TextView mTime;//录制时间
- private DrawableRadioButton2 mBtnFlash;//闪光灯按钮
- private TXUGCRecord mRecorder;//录制器
- private TXRecordCommon.TXUGCCustomConfig mCustomConfig;//录制相关配置
- private boolean mFrontCamera = true;//是否是前置摄像头
- private String mVideoPath;//视频的保存路径
- private int mRecordSpeed;//录制速度
- private View mGroup1;
- private View mGroup2;
- private View mGroup3;
- private View mGroup4;
- private View mBtnNext;//录制完成,下一步
- private Dialog mStopRecordDialog;//停止录制的时候的dialog
- private boolean mIsReachMaxRecordDuration;//是否达到最大录制时间
- private long mDuration;//录制视频的长度
- private BeautyViewHolder mBeautyViewHolder;
- private TiSDKManager mTiSDKManager;//萌颜的各种工具
- private VideoMusicViewHolder mVideoMusicViewHolder;
- private MusicBean mMusicBean;//背景音乐
- private boolean mHasBgm;
- private boolean mBgmPlayStarted;//是否已经开始播放背景音乐了
- private Bitmap mFilterBitmap;//基础美颜的滤镜
- //萌颜美颜效果
- private int mMeibai = 0;//美白
- private int mMoPi = 0;//磨皮
- private int mBaoHe = 0;//饱和
- private int mFengNen = 0;//粉嫩
- private int mBigEye = 0;//大眼
- private int mFace = 0;//瘦脸
- private int mFaceNarrowing = 0;//窄脸
- private String mTieZhi = "";//贴纸
- private TiFilterEnum mTiFilterEnum = TiFilterEnum.NO_FILTER;//滤镜
- private TiDistortionEnum mTiDistortionEnum = TiDistortionEnum.NO_DISTORTION;//哈哈镜
- private TiRockEnum mTiRockEnum = TiRockEnum.NO_ROCK;//抖动
- private boolean mFristInitBeauty = true;
- private long mRecordTime;
- String mBeautySdkType;
- @Override
- protected int getLayoutId() {
- return R.layout.activity_video_record;
- }
-
- @Override
- protected boolean isStatusBarWhite() {
- return true;
- }
-
- @Override
- protected void main() {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- //按钮动画相关
- mVideoRecordBtnView = (VideoRecordBtnView) findViewById(R.id.record_btn_view);
- mRecordView = findViewById(R.id.record_view);
- mUnRecordDrawable = ContextCompat.getDrawable(mContext, R.drawable.bg_btn_record_1);
- mRecordDrawable = ContextCompat.getDrawable(mContext, R.drawable.bg_btn_record_2);
- mRecordBtnAnimator = ValueAnimator.ofFloat(100, 0);
- mRecordBtnAnimator.setDuration(500);
- mRecordBtnAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float v = (float) animation.getAnimatedValue();
- if (mVideoRecordBtnView != null) {
- mVideoRecordBtnView.setRate((int) v);
- }
- }
- });
- mRecordBtnAnimator.setRepeatCount(-1);
- mRecordBtnAnimator.setRepeatMode(ValueAnimator.REVERSE);
-
- /****************************/
- mRoot = (ViewGroup) findViewById(R.id.root);
- mGroup1 = findViewById(R.id.group_1);
- mGroup2 = findViewById(R.id.group_2);
- mGroup3 = findViewById(R.id.group_3);
- mGroup4 = findViewById(R.id.group_4);
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
- //mVideoView.enableHardwareDecode(true);
- mTime = findViewById(R.id.time);
- mRecordProgressView = (RecordProgressView) findViewById(R.id.record_progress_view);
- mRecordProgressView.setMaxDuration(MAX_DURATION);
- mRecordProgressView.setMinDuration(MIN_DURATION);
- mBtnFlash = (DrawableRadioButton2) findViewById(R.id.btn_flash);
- mBtnNext = findViewById(R.id.btn_next);
- initCameraRecord();
-
- mBeautySdkType= CommonAppConfig.getInstance().getBeautySdkType();
-
- }
-
- /**
- * 初始化录制器
- */
- private void initCameraRecord() {
- mRecorder = TXUGCRecord.getInstance(CommonAppContext.sInstance);
- mRecorder.setHomeOrientation(TXLiveConstants.VIDEO_ANGLE_HOME_DOWN);
- mRecorder.setRenderRotation(TXLiveConstants.RENDER_ROTATION_PORTRAIT);
- mRecordSpeed = TXRecordCommon.RECORD_SPEED_NORMAL;
- mRecorder.setRecordSpeed(mRecordSpeed);
- mRecorder.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_9_16);
- mCustomConfig = new TXRecordCommon.TXUGCCustomConfig();
- mCustomConfig.videoResolution = TXRecordCommon.VIDEO_RESOLUTION_1080_1920;
- mCustomConfig.minDuration = MIN_DURATION;
- mCustomConfig.maxDuration = MAX_DURATION;
- mCustomConfig.videoBitrate = 6500;
- mCustomConfig.videoGop = 3;
- mCustomConfig.videoFps = 20;
- mCustomConfig.isFront = mFrontCamera;
- mRecorder.setVideoRecordListener(this);
- }
-
-
- /**
- * 初始化萌颜
- */
- private void initBeauty() {
- try {
- mTiSDKManager = new TiSDKManagerBuilder().build();
- mTiSDKManager.setBeautyEnable(true);
- mTiSDKManager.setFaceTrimEnable(true);
- if (mFristInitBeauty) {
- mFristInitBeauty = false;
- ConfigBean configBean = CommonAppConfig.getInstance().getConfig();
- if (configBean != null) {
- mMeibai = configBean.getBeautyMeiBai();//美白
- mMoPi = configBean.getBeautyMoPi();//磨皮
- mBaoHe = configBean.getBeautyBaoHe();//饱和
- mFengNen = configBean.getBeautyFenNen();//粉嫩
- mBigEye = configBean.getBeautyBigEye();//大眼
- mFace = configBean.getBeautyFace();//瘦脸
- mFaceNarrowing = configBean.getBeautyFaceNarrowing();//窄脸
- }
- }
- mTiSDKManager.setSkinWhitening(mMeibai);//美白
- mTiSDKManager.setSkinBlemishRemoval(mMoPi);//磨皮
- mTiSDKManager.setSkinSaturation(mBaoHe);//饱和
- mTiSDKManager.setSkinTenderness(mFengNen);//粉嫩
- mTiSDKManager.setEyeMagnifying(mBigEye);//大眼
- mTiSDKManager.setChinSlimming(mFace);//瘦脸
- mTiSDKManager.setFaceNarrowing(mFaceNarrowing);//窄脸
- mTiSDKManager.setSticker(mTieZhi);//贴纸
- mTiSDKManager.setFilterEnum(mTiFilterEnum);//滤镜
- mTiSDKManager.setDistortionEnum(mTiDistortionEnum);//哈哈镜
-
- } catch (Exception e) {
- ToastUtil.show(R.string.beauty_init_error);
- }
- }
-
- /**
- * 录制回调
- */
- @Override
- public void onRecordEvent(int event, Bundle bundle) {
- if (event == TXRecordCommon.EVT_ID_PAUSE) {
- if (mRecordProgressView != null) {
- mRecordProgressView.clipComplete();
- }
- } else if (event == TXRecordCommon.EVT_CAMERA_CANNOT_USE) {
- ToastUtil.show(R.string.video_record_camera_failed);
- } else if (event == TXRecordCommon.EVT_MIC_CANNOT_USE) {
- ToastUtil.show(R.string.video_record_audio_failed);
- }
- }
-
- /**
- * 录制回调 录制进度
- */
- @Override
- public void onRecordProgress(long milliSecond) {
- if (mRecordProgressView != null) {
- mRecordProgressView.setProgress((int) milliSecond);
- }
- if (mTime != null) {
- mTime.setText(String.format("%.2f", milliSecond / 1000f) + "s");
- }
- mRecordTime = milliSecond;
- if (milliSecond >= MIN_DURATION) {
- if (mBtnNext != null && mBtnNext.getVisibility() != View.VISIBLE) {
- mBtnNext.setVisibility(View.VISIBLE);
- }
- }
- if (milliSecond >= MAX_DURATION) {
- if (!mIsReachMaxRecordDuration) {
- mIsReachMaxRecordDuration = true;
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.cancel();
- }
- showProccessDialog();
- }
- }
- }
-
- /**
- * 录制回调
- */
- @Override
- public void onRecordComplete(TXRecordCommon.TXRecordResult result) {
- hideProccessDialog();
- mRecordStarted = false;
- mRecordStoped = true;
- if (mRecorder != null) {
- mRecorder.toggleTorch(false);
- mRecorder.stopBGM();
- mDuration = mRecorder.getPartsManager().getDuration();
- }
- if (result.retCode < 0) {
- release();
- ToastUtil.show(R.string.video_record_failed);
- } else {
- VideoEditActivity.forward(mContext, mDuration, mVideoPath, true, mHasBgm);
- }
- finish();
- }
-
-
- /**
- * 录制中美颜处理回调
- */
- @Override
- public int onTextureCustomProcess(int i, int i1, int i2) {
- if (mTiSDKManager != null) {
- return mTiSDKManager.renderTexture2D(i, i1, i2, TiRotation.CLOCKWISE_ROTATION_0, false);
- }
- return 0;
- }
-
- /**
- * 录制中美颜处理回调
- */
- @Override
- public void onDetectFacePoints(float[] floats) {
-
- }
-
- /**
- * 录制中美颜处理回调
- */
- @Override
- public void onTextureDestroyed() {
-
- }
-
- public void recordClick(View v) {
- if (mRecordStoped || !canClick()) {
- return;
- }
- int i = v.getId();
- if (i == R.id.btn_start_record) {
- clickRecord();
-
- } else if (i == R.id.btn_camera) {
- clickCamera();
-
- } else if (i == R.id.btn_flash) {
- clickFlash();
-
- } else if (i == R.id.btn_beauty) {
- clickBeauty();
-
- } else if (i == R.id.btn_music) {
- clickMusic();
-
- } else if (i == R.id.btn_speed_1) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_SLOWEST);
-
- } else if (i == R.id.btn_speed_2) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_SLOW);
-
- } else if (i == R.id.btn_speed_3) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_NORMAL);
-
- } else if (i == R.id.btn_speed_4) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_FAST);
-
- } else if (i == R.id.btn_speed_5) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_FASTEST);
-
- } else if (i == R.id.btn_upload) {
- clickUpload();
-
- } else if (i == R.id.btn_delete) {
- clickDelete();
-
- } else if (i == R.id.btn_next) {
- clickNext();
-
- }
- }
-
- /**
- * 点击摄像头
- */
- private void clickCamera() {
- if (mRecorder != null) {
- if (mBtnFlash != null && mBtnFlash.isChecked()) {
- mBtnFlash.doToggle();
- mRecorder.toggleTorch(mBtnFlash.isChecked());
- }
- mFrontCamera = !mFrontCamera;
- mRecorder.switchCamera(mFrontCamera);
- }
- }
-
- /**
- * 点击闪光灯
- */
- private void clickFlash() {
- if (mFrontCamera) {
- ToastUtil.show(R.string.live_open_flash);
- return;
- }
- if (mBtnFlash != null) {
- mBtnFlash.doToggle();
- if (mRecorder != null) {
- mRecorder.toggleTorch(mBtnFlash.isChecked());
- }
- }
- }
-
- /**
- * 点击美颜
- */
- private void clickBeauty() {
- if (mBeautyViewHolder == null) {
- if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
- mBeautyViewHolder = new TiBeautyViewHolder(mContext, mRoot);
- } else {
- mBeautyViewHolder = new DefaultBeautyViewHolder(mContext, mRoot);
- }
-
-// if ("2".equals(mBeautySdkType)) {
-// mBeautyViewHolder = new TiBeautyViewHolder(mContext, mRoot);
-// } else if ("3".equals(mBeautySdkType)){
-// mBeautyViewHolder = new Beauty360ViewHolder(this, mRoot);
-// }else {
-// mBeautyViewHolder = new DefaultBeautyViewHolder(mContext, mRoot);
-// }
-
-
- mBeautyViewHolder.setVisibleListener(new DefaultBeautyViewHolder.VisibleListener() {
- @Override
- public void onVisibleChanged(boolean visible) {
- if (mGroup1 != null) {
- if (visible) {
- if (mGroup1.getVisibility() == View.VISIBLE) {
- mGroup1.setVisibility(View.INVISIBLE);
- }
- } else {
- if (mGroup1.getVisibility() != View.VISIBLE) {
- mGroup1.setVisibility(View.VISIBLE);
- }
- }
- }
- }
- });
-
-
-
- if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
- mBeautyViewHolder.setEffectListener(this);//萌颜
- } else {
- mBeautyViewHolder.setEffectListener(mBaseBeautyEffectListener);//基础美颜
- }
-
-// if ("2".equals(mBeautySdkType)) {
-// mBeautyViewHolder.setEffectListener(this);//萌颜
-// } else if ("3".equals(mBeautySdkType)){
-// mBeautyViewHolder.setEffectListener(mBeauty360EffectListener);//360美颜
-// }else {
-// mBeautyViewHolder.setEffectListener(mBaseBeautyEffectListener);//基础美颜
-// }
-
- }
- mBeautyViewHolder.show();
- }
-
- private Beauty360EffectListener mBeauty360EffectListener = new Beauty360EffectListener() {
-
- @Override
- public void onFilterChanged(String filtertype) {
-
- }
-
- @Override
- public void onFilterStrength(int filterValue) {
-
- }
-
- @Override
- public void onMeiBaiChanged(int progress) {
-
- }
-
- @Override
- public void onSkinsoftStrengthChanged(int progress) {
-
- }
-
- @Override
- public void onHongRunChanged(int progress) {
-
- }
-
- @Override
- public void onFengNenChanged(int progress) {
-
- }
-
- @Override
- public void onBigEyeChanged(int progress) {
-
- }
-
- @Override
- public void onFaceChanged(int progress) {
-
- }
-
- @Override
- public void onTieZhiChanged(String tieZhiName) {
-
- }
-
- @Override
- public void onHaHaChanged(TiDistortionEnum tiDistortionEnum) {
-
- }
-
- @Override
- public void onRockChanged(TiRockEnum tiRockEnum) {
-
- }
-
- @Override
- public void onFaceNarrowing(int progress) {
-
- }
- };
- //基础美颜的回调 (非萌颜)
- private DefaultBeautyEffectListener mBaseBeautyEffectListener = new DefaultBeautyEffectListener() {
- @Override
- public void onFilterChanged(FilterBean filterBean) {
- if (mFilterBitmap != null) {
- mFilterBitmap.recycle();
- }
- if (mRecorder != null) {
- int filterSrc = filterBean.getFilterSrc();
- if (filterSrc != 0) {
- Bitmap bitmap = BitmapUtil.getInstance().decodeBitmap(filterSrc);
- if (bitmap != null) {
- mFilterBitmap = bitmap;
- mRecorder.setFilter(bitmap);
- } else {
- mRecorder.setFilter(null);
- }
- } else {
- mRecorder.setFilter(null);
- }
- }
- }
-
- @Override
- public void onMeiBaiChanged(int progress) {
- if (mRecorder != null) {
- int v = progress / 10;
- if (mMeibai != v) {
- mMeibai = v;
- mRecorder.setBeautyDepth(0, mMoPi, mMeibai, mFengNen);
- }
- }
-
- }
-
- @Override
- public void onMoPiChanged(int progress) {
- if (mRecorder != null) {
- int v = progress / 10;
- if (mMoPi != v) {
- mMoPi = v;
- mRecorder.setBeautyDepth(0, mMoPi, mMeibai, mFengNen);
- }
- }
- }
-
- @Override
- public void onHongRunChanged(int progress) {
- if (mRecorder != null) {
- int v = progress / 10;
- if (mFengNen != v) {
- mFengNen = v;
- mRecorder.setBeautyDepth(0, mMoPi, mMeibai, mFengNen);
- }
- }
- }
- };
-
- /**
- * 点击音乐
- */
- private void clickMusic() {
- if (mVideoMusicViewHolder == null) {
- mVideoMusicViewHolder = new VideoMusicViewHolder(mContext, mRoot);
- mVideoMusicViewHolder.setActionListener(new VideoMusicViewHolder.ActionListener() {
- @Override
- public void onChooseMusic(MusicBean musicBean) {
- mMusicBean = musicBean;
- mBgmPlayStarted = false;
- }
- });
- mVideoMusicViewHolder.addToParent();
- mVideoMusicViewHolder.subscribeActivityLifeCycle();
- }
- mVideoMusicViewHolder.show();
- }
-
- /**
- * 点击上传,选择本地视频
- */
- private void clickUpload() {
- Intent intent = new Intent(mContext, VideoChooseActivity.class);
- intent.putExtra(Constants.VIDEO_DURATION, MAX_DURATION);
- startActivityForResult(intent, 0);
- }
-
- /**
- * 选择本地视频的回调
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == 0 && resultCode == RESULT_OK) {
- mVideoPath = data.getStringExtra(Constants.VIDEO_PATH);
- mDuration = data.getLongExtra(Constants.VIDEO_DURATION, 0);
- VideoEditActivity.forward(mContext, mDuration, mVideoPath, false, false);
- finish();
- }
- }
-
-
- /**
- * 开始预览
- */
- private void startCameraPreview() {
- if (mRecorder != null && mCustomConfig != null && mVideoView != null) {
- mRecorder.startCameraCustomPreview(mCustomConfig, mVideoView);
- if (!mFrontCamera) {
- mRecorder.switchCamera(false);
- }
-
-
- if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
- initBeauty();
- mRecorder.setVideoProcessListener(this);
- }
-
-// if ("2".equals(mBeautySdkType)) {
-// initBeauty();
-// mRecorder.setVideoProcessListener(this);
-// } else if ("3".equals(mBeautySdkType)){
-//
-// }else {
-//
-// }
- }
- }
-
- /**
- * 停止预览
- */
- private void stopCameraPreview() {
- if (mRecorder != null) {
- if (mRecording) {
- pauseRecord();
- }
- mRecorder.stopCameraPreview();
- mRecorder.setVideoProcessListener(null);
- if (mTiSDKManager != null) {
- mTiSDKManager.destroy();
- }
- mTiSDKManager = null;
- }
- }
-
- /**
- * 点击录制
- */
- private void clickRecord() {
- if (mRecordStarted) {
- if (mRecording) {
- pauseRecord();
- } else {
- resumeRecord();
- }
- } else {
- startRecord();
- }
- }
-
- /**
- * 开始录制
- */
- private void startRecord() {
- if (mRecorder != null) {
- mVideoPath = StringUtil.generateVideoOutputPath();//视频保存的路径
- int result = mRecorder.startRecord(mVideoPath, CommonAppConfig.VIDEO_RECORD_TEMP_PATH, null);//为空表示不需要生成视频封面
- if (result != TXRecordCommon.START_RECORD_OK) {
- if (result == TXRecordCommon.START_RECORD_ERR_NOT_INIT) {
- ToastUtil.show(R.string.video_record_tip_1);
- } else if (result == TXRecordCommon.START_RECORD_ERR_IS_IN_RECORDING) {
- ToastUtil.show(R.string.video_record_tip_2);
- } else if (result == TXRecordCommon.START_RECORD_ERR_VIDEO_PATH_IS_EMPTY) {
- ToastUtil.show(R.string.video_record_tip_3);
- } else if (result == TXRecordCommon.START_RECORD_ERR_API_IS_LOWER_THAN_18) {
- ToastUtil.show(R.string.video_record_tip_4);
- } else if (result == TXRecordCommon.START_RECORD_ERR_LICENCE_VERIFICATION_FAILED) {
- ToastUtil.show(R.string.video_record_tip_5);
- }
- return;
- }
- }
- mRecordStarted = true;
- mRecording = true;
- resumeBgm();
- startRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() == View.VISIBLE) {
- mGroup2.setVisibility(View.INVISIBLE);
- }
- }
-
-
- /**
- * 暂停录制
- */
- private void pauseRecord() {
- if (mRecorder == null) {
- return;
- }
- pauseBgm();
- mRecorder.pauseRecord();
- mRecording = false;
- stopRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() != View.VISIBLE) {
- mGroup2.setVisibility(View.VISIBLE);
- }
- TXUGCPartsManager partsManager = mRecorder.getPartsManager();
- if (partsManager != null) {
- List partList = partsManager.getPartsPathList();
- if (partList != null && partList.size() > 0) {
- if (mGroup3 != null && mGroup3.getVisibility() == View.VISIBLE) {
- mGroup3.setVisibility(View.INVISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() != View.VISIBLE) {
- mGroup4.setVisibility(View.VISIBLE);
- }
- } else {
- if (mGroup3 != null && mGroup3.getVisibility() != View.VISIBLE) {
- mGroup3.setVisibility(View.VISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() == View.VISIBLE) {
- mGroup4.setVisibility(View.INVISIBLE);
- }
- }
- }
- }
-
- /**
- * 恢复录制
- */
- private void resumeRecord() {
- if (mRecorder != null) {
- int startResult = mRecorder.resumeRecord();
- if (startResult != TXRecordCommon.START_RECORD_OK) {
- ToastUtil.show(WordUtil.getString(R.string.video_record_failed));
- return;
- }
- }
- mRecording = true;
- resumeBgm();
- startRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() == View.VISIBLE) {
- mGroup2.setVisibility(View.INVISIBLE);
- }
- }
-
- /**
- * 暂停背景音乐
- */
- private void pauseBgm() {
- if (mRecorder != null) {
- mRecorder.pauseBGM();
- }
- }
-
- /**
- * 恢复背景音乐
- */
- private void resumeBgm() {
- if (mRecorder == null) {
- return;
- }
- if (!mBgmPlayStarted) {
- if (mMusicBean == null) {
- return;
- }
- int bgmDuration = mRecorder.setBGM(mMusicBean.getLocalPath());
- mRecorder.playBGMFromTime(0, bgmDuration);
- mRecorder.setBGMVolume(1);//背景音为1最大
- mRecorder.setMicVolume(0);//原声音为0
- mBgmPlayStarted = true;
- mHasBgm = true;
- } else {
- mRecorder.resumeBGM();
- }
- }
-
- /**
- * 按钮录制动画开始
- */
- private void startRecordBtnAnim() {
- if (mRecordView != null) {
- mRecordView.setBackground(mRecordDrawable);
- }
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.start();
- }
- }
-
- /**
- * 按钮录制动画停止
- */
- private void stopRecordBtnAnim() {
- if (mRecordView != null) {
- mRecordView.setBackground(mUnRecordDrawable);
- }
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.cancel();
- }
- if (mVideoRecordBtnView != null) {
- mVideoRecordBtnView.reset();
- }
- }
-
- /**
- * 调整录制速度
- */
- private void changeRecordSpeed(int speed) {
- if (mRecordSpeed == speed) {
- return;
- }
- mRecordSpeed = speed;
- if (mRecorder != null) {
- mRecorder.setRecordSpeed(speed);
- }
- }
-
- /**
- * 删除录制分段
- */
- private void clickDelete() {
- DialogUitl.showSimpleDialog(mContext, WordUtil.getString(R.string.video_record_delete_last), new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- doClickDelete();
- }
- });
- }
-
- /**
- * 删除录制分段
- */
- private void doClickDelete() {
- if (!mRecordStarted || mRecording || mRecorder == null) {
- return;
- }
- TXUGCPartsManager partsManager = mRecorder.getPartsManager();
- if (partsManager == null) {
- return;
- }
- List partList = partsManager.getPartsPathList();
- if (partList == null || partList.size() == 0) {
- return;
- }
- partsManager.deleteLastPart();
- int time = partsManager.getDuration();
- if (mTime != null) {
- mTime.setText(String.format("%.2f", time / 1000f) + "s");
- }
- mRecordTime = time;
- if (time < MIN_DURATION && mBtnNext != null && mBtnNext.getVisibility() == View.VISIBLE) {
- mBtnNext.setVisibility(View.INVISIBLE);
- }
- if (mRecordProgressView != null) {
- mRecordProgressView.deleteLast();
- }
- partList = partsManager.getPartsPathList();
- if (partList != null && partList.size() == 0) {
- if (mGroup2 != null && mGroup2.getVisibility() != View.VISIBLE) {
- mGroup2.setVisibility(View.VISIBLE);
- }
- if (mGroup3 != null && mGroup3.getVisibility() != View.VISIBLE) {
- mGroup3.setVisibility(View.VISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() == View.VISIBLE) {
- mGroup4.setVisibility(View.INVISIBLE);
- }
- }
- }
-
- /**
- * 结束录制,会触发 onRecordComplete
- */
- public void clickNext() {
- stopRecordBtnAnim();
- if (mRecorder != null) {
- mRecorder.stopBGM();
- mRecorder.stopRecord();
- showProccessDialog();
- }
- }
-
-
- /**
- * 录制结束时候显示处理中的弹窗
- */
- private void showProccessDialog() {
- if (mStopRecordDialog == null) {
- mStopRecordDialog = DialogUitl.loadingDialog(mContext, WordUtil.getString(R.string.video_processing));
- mStopRecordDialog.show();
- }
- }
-
- /**
- * 隐藏处理中的弹窗
- */
- private void hideProccessDialog() {
- if (mStopRecordDialog != null) {
- mStopRecordDialog.dismiss();
- }
- mStopRecordDialog = null;
- }
-
-
- @Override
- public void onBackPressed() {
- if (!canClick()) {
- return;
- }
- if (mBeautyViewHolder != null && mBeautyViewHolder.isShowed()) {
- mBeautyViewHolder.hide();
- return;
- }
- if (mVideoMusicViewHolder != null && mVideoMusicViewHolder.isShowed()) {
- mVideoMusicViewHolder.hide();
- return;
- }
- List list = new ArrayList<>();
- if (mRecordTime > 0) {
- list.add(R.string.video_re_record);
- }
- list.add(R.string.video_exit);
- DialogUitl.showStringArrayDialog(mContext, list.toArray(new Integer[list.size()]), new DialogUitl.StringArrayDialogCallback() {
- @Override
- public void onItemClick(String text, int tag) {
- if (tag == R.string.video_re_record) {
- reRecord();
- } else if (tag == R.string.video_exit) {
- exit();
- }
- }
- });
- }
-
- /**
- * 重新录制
- */
- private void reRecord() {
- if (mRecorder == null) {
- return;
- }
- mRecorder.pauseBGM();
- mMusicBean = null;
- mHasBgm = false;
- mBgmPlayStarted = false;
- mRecorder.pauseRecord();
- mRecording = false;
- stopRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() != View.VISIBLE) {
- mGroup2.setVisibility(View.VISIBLE);
- }
- TXUGCPartsManager partsManager = mRecorder.getPartsManager();
- if (partsManager != null) {
- partsManager.deleteAllParts();
- }
- mRecorder.onDeleteAllParts();
- if (mTime != null) {
- mTime.setText("0.00s");
- }
- mRecordTime = 0;
- if (mBtnNext != null && mBtnNext.getVisibility() == View.VISIBLE) {
- mBtnNext.setVisibility(View.INVISIBLE);
- }
- if (mRecordProgressView != null) {
- mRecordProgressView.deleteAll();
- }
- if (mGroup3 != null && mGroup3.getVisibility() != View.VISIBLE) {
- mGroup3.setVisibility(View.VISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() == View.VISIBLE) {
- mGroup4.setVisibility(View.INVISIBLE);
- }
-
- }
-
- /**
- * 退出
- */
- private void exit() {
- release();
- super.onBackPressed();
- }
-
-
- @Override
- protected void onStart() {
- super.onStart();
- startCameraPreview();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- stopCameraPreview();
- if (mRecorder != null && mBtnFlash != null && mBtnFlash.isChecked()) {
- mBtnFlash.doToggle();
- mRecorder.toggleTorch(mBtnFlash.isChecked());
- }
- }
-
- @Override
- protected void onDestroy() {
- release();
- super.onDestroy();
- L.e(TAG, "-------->onDestroy");
- }
-
-
- private void release() {
- if (mStopRecordDialog != null && mStopRecordDialog.isShowing()) {
- mStopRecordDialog.dismiss();
- }
- if (mBeautyViewHolder != null) {
- mBeautyViewHolder.release();
- }
- if (mVideoMusicViewHolder != null) {
- mVideoMusicViewHolder.release();
- }
- if (mRecordProgressView != null) {
- mRecordProgressView.release();
- }
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.cancel();
- }
- if (mRecorder != null) {
- mRecorder.toggleTorch(false);
- mRecorder.stopBGM();
- if (mRecordStarted) {
- mRecorder.stopRecord();
- }
- mRecorder.stopCameraPreview();
- mRecorder.setVideoProcessListener(null);
- mRecorder.setVideoRecordListener(null);
- TXUGCPartsManager getPartsManager = mRecorder.getPartsManager();
- if (getPartsManager != null) {
- getPartsManager.deleteAllParts();
- }
- mRecorder.release();
- }
- if (mTiSDKManager != null) {
- mTiSDKManager.destroy();
- }
- mStopRecordDialog = null;
- mBeautyViewHolder = null;
- mVideoMusicViewHolder = null;
- mRecordProgressView = null;
- mRecordBtnAnimator = null;
- mRecorder = null;
- mTiSDKManager = null;
-
- }
-
-
- /****************美颜回调 start********************/
- /**
- * 设置滤镜回调
- */
- @Override
- public void onFilterChanged(TiFilterEnum tiFilterEnum) {
- if (mTiSDKManager != null) {
- mTiFilterEnum = tiFilterEnum;
- mTiSDKManager.setFilterEnum(tiFilterEnum);
- }
- }
-
- /**
- * 设置美白回调
- */
- @Override
- public void onMeiBaiChanged(int progress) {
- if (mTiSDKManager != null) {
- mMeibai = progress;
- mTiSDKManager.setSkinWhitening(progress);
- }
- }
-
- /**
- * 设置磨皮回调
- */
- @Override
- public void onMoPiChanged(int progress) {
- if (mTiSDKManager != null) {
- mMoPi = progress;
- mTiSDKManager.setSkinBlemishRemoval(progress);
- }
- }
-
- /**
- * 设置饱和回调
- */
- @Override
- public void onBaoHeChanged(int progress) {
- if (mTiSDKManager != null) {
- mBaoHe = progress;
- mTiSDKManager.setSkinSaturation(progress);
- }
- }
-
- /**
- * 设置粉嫩回调
- */
- @Override
- public void onFengNenChanged(int progress) {
- if (mTiSDKManager != null) {
- mFengNen = progress;
- mTiSDKManager.setSkinTenderness(progress);
- }
- }
-
- /**
- * 设置大眼回调
- */
- @Override
- public void onBigEyeChanged(int progress) {
- if (mTiSDKManager != null) {
- mBigEye = progress;
- mTiSDKManager.setEyeMagnifying(progress);
- }
- }
-
- /**
- * 设置瘦脸回调
- */
- @Override
- public void onFaceChanged(int progress) {
- if (mTiSDKManager != null) {
- mFace = progress;
- mTiSDKManager.setChinSlimming(progress);
- }
- }
- /**
- * 设置窄脸回调
- */
- @Override
- public void onFaceNarrowing(int progress) {
- if (mTiSDKManager != null) {
- mFaceNarrowing = progress;
- mTiSDKManager.setFaceNarrowing(progress);
- }
- }
- /**
- * 设置贴纸回调
- */
- @Override
- public void onTieZhiChanged(String tieZhiName) {
- if (mTiSDKManager != null) {
- mTieZhi = tieZhiName;
- mTiSDKManager.setSticker(tieZhiName);
- }
- }
-
- /**
- * 设置哈哈镜回调
- */
- @Override
- public void onHaHaChanged(TiDistortionEnum tiDistortionEnum) {
- if (mTiSDKManager != null) {
- mTiDistortionEnum = tiDistortionEnum;
- mTiSDKManager.setDistortionEnum(tiDistortionEnum);
- }
- }
-
- /**
- * 设置抖动回调
- */
- @Override
- public void onRockChanged(TiRockEnum tiRockEnum) {
- if (mTiSDKManager != null) {
- mTiRockEnum = tiRockEnum;
- mTiSDKManager.setRockEnum(tiRockEnum);
- }
- }
-
-}
diff --git a/video/src/main/java/com/yunbao/video/activity/VideoRecordActivity.java b/video/src/main/java/com/yunbao/video/activity/VideoRecordActivity.java
deleted file mode 100644
index e789488e3..000000000
--- a/video/src/main/java/com/yunbao/video/activity/VideoRecordActivity.java
+++ /dev/null
@@ -1,1193 +0,0 @@
-package com.yunbao.video.activity;
-
-import android.animation.ValueAnimator;
-import android.app.Dialog;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import androidx.core.content.ContextCompat;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.TextView;
-
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.tencent.ugc.TXRecordCommon;
-import com.tencent.ugc.TXUGCPartsManager;
-import com.tencent.ugc.TXUGCRecord;
-import com.yunbao.beauty.bean.FilterBean;
-import com.yunbao.beauty.interfaces.Beauty360EffectListener;
-import com.yunbao.beauty.interfaces.BeautyViewHolder;
-import com.yunbao.beauty.interfaces.DefaultBeautyEffectListener;
-import com.yunbao.beauty.interfaces.TiBeautyEffectListener;
-import com.yunbao.beauty.views.DefaultBeautyViewHolder;
-import com.yunbao.beauty.views.TiBeautyViewHolder;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.CommonAppContext;
-import com.yunbao.common.Constants;
-import com.yunbao.common.activity.AbsActivity;
-import com.yunbao.common.bean.ConfigBean;
-import com.yunbao.common.custom.DrawableRadioButton2;
-import com.yunbao.common.utils.BitmapUtil;
-import com.yunbao.common.utils.DialogUitl;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.StringUtil;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.utils.WordUtil;
-import com.yunbao.video.R;
-import com.yunbao.video.bean.MusicBean;
-import com.yunbao.video.custom.RecordProgressView;
-import com.yunbao.video.custom.VideoRecordBtnView;
-import com.yunbao.video.views.VideoMusicViewHolder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import cn.tillusory.sdk.TiSDKManager;
-import cn.tillusory.sdk.TiSDKManagerBuilder;
-import cn.tillusory.sdk.bean.TiDistortionEnum;
-import cn.tillusory.sdk.bean.TiFilterEnum;
-import cn.tillusory.sdk.bean.TiRockEnum;
-import cn.tillusory.sdk.bean.TiRotation;
-
-/**
- * Created by cxf on 2018/12/5.
- * 视频录制
- */
-
-public class VideoRecordActivity extends AbsActivity implements
- TXRecordCommon.ITXVideoRecordListener, //视频录制进度回调
- TiBeautyEffectListener, //设置美颜数值回调
- TXUGCRecord.VideoCustomProcessListener //视频录制中自定义预处理(添加美颜回调)
-{
-
- private static final String TAG = "VideoRecordActivity";
- private static final int MIN_DURATION = 5000;//最小录制时间5s
- private static final int MAX_DURATION = 15000;//最大录制时间15s
- //按钮动画相关
- private VideoRecordBtnView mVideoRecordBtnView;
- private View mRecordView;
- private ValueAnimator mRecordBtnAnimator;//录制开始后,录制按钮动画
- private Drawable mRecordDrawable;
- private Drawable mUnRecordDrawable;
-
- /****************************/
- private boolean mRecordStarted;//是否开始了录制(true 已开始 false 未开始)
- private boolean mRecordStoped;//是否结束了录制
- private boolean mRecording;//是否在录制中((true 录制中 false 暂停中)
- private ViewGroup mRoot;
- private TXCloudVideoView mVideoView;//预览控件
- private RecordProgressView mRecordProgressView;//录制进度条
- private TextView mTime;//录制时间
- private DrawableRadioButton2 mBtnFlash;//闪光灯按钮
- private TXUGCRecord mRecorder;//录制器
- private TXRecordCommon.TXUGCCustomConfig mCustomConfig;//录制相关配置
- private boolean mFrontCamera = true;//是否是前置摄像头
- private String mVideoPath;//视频的保存路径
- private int mRecordSpeed;//录制速度
- private View mGroup1;
- private View mGroup2;
- private View mGroup3;
- private View mGroup4;
- private View mBtnNext;//录制完成,下一步
- private Dialog mStopRecordDialog;//停止录制的时候的dialog
- private boolean mIsReachMaxRecordDuration;//是否达到最大录制时间
- private long mDuration;//录制视频的长度
- private BeautyViewHolder mBeautyViewHolder;
- private TiSDKManager mTiSDKManager;//萌颜的各种工具
- private VideoMusicViewHolder mVideoMusicViewHolder;
- private MusicBean mMusicBean;//背景音乐
- private boolean mHasBgm;
- private boolean mBgmPlayStarted;//是否已经开始播放背景音乐了
- private Bitmap mFilterBitmap;//基础美颜的滤镜
- //萌颜美颜效果
- private int mMeibai = 0;//美白
- private int mMoPi = 0;//磨皮
- private int mBaoHe = 0;//饱和
- private int mFengNen = 0;//粉嫩
- private int mBigEye = 0;//大眼
- private int mFace = 0;//瘦脸
- private int mFaceNarrowing = 0;//窄脸
- private String mTieZhi = "";//贴纸
- private TiFilterEnum mTiFilterEnum = TiFilterEnum.NO_FILTER;//滤镜
- private TiDistortionEnum mTiDistortionEnum = TiDistortionEnum.NO_DISTORTION;//哈哈镜
- private TiRockEnum mTiRockEnum = TiRockEnum.NO_ROCK;//抖动
- private boolean mFristInitBeauty = true;
- private long mRecordTime;
- String mBeautySdkType;
- @Override
- protected int getLayoutId() {
- return R.layout.activity_video_record;
- }
-
- @Override
- protected boolean isStatusBarWhite() {
- return true;
- }
-
- @Override
- protected void main() {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- //按钮动画相关
- mVideoRecordBtnView = (VideoRecordBtnView) findViewById(R.id.record_btn_view);
- mRecordView = findViewById(R.id.record_view);
- mUnRecordDrawable = ContextCompat.getDrawable(mContext, R.drawable.bg_btn_record_1);
- mRecordDrawable = ContextCompat.getDrawable(mContext, R.drawable.bg_btn_record_2);
- mRecordBtnAnimator = ValueAnimator.ofFloat(100, 0);
- mRecordBtnAnimator.setDuration(500);
- mRecordBtnAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float v = (float) animation.getAnimatedValue();
- if (mVideoRecordBtnView != null) {
- mVideoRecordBtnView.setRate((int) v);
- }
- }
- });
- mRecordBtnAnimator.setRepeatCount(-1);
- mRecordBtnAnimator.setRepeatMode(ValueAnimator.REVERSE);
-
- /****************************/
- mRoot = (ViewGroup) findViewById(R.id.root);
- mGroup1 = findViewById(R.id.group_1);
- mGroup2 = findViewById(R.id.group_2);
- mGroup3 = findViewById(R.id.group_3);
- mGroup4 = findViewById(R.id.group_4);
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
- //mVideoView.enableHardwareDecode(true);
- mTime = findViewById(R.id.time);
- mRecordProgressView = (RecordProgressView) findViewById(R.id.record_progress_view);
- mRecordProgressView.setMaxDuration(MAX_DURATION);
- mRecordProgressView.setMinDuration(MIN_DURATION);
- mBtnFlash = (DrawableRadioButton2) findViewById(R.id.btn_flash);
- mBtnNext = findViewById(R.id.btn_next);
- initCameraRecord();
-
- mBeautySdkType= CommonAppConfig.getInstance().getBeautySdkType();
-
- }
-
- /**
- * 初始化录制器
- */
- private void initCameraRecord() {
- mRecorder = TXUGCRecord.getInstance(CommonAppContext.sInstance);
- mRecorder.setHomeOrientation(TXLiveConstants.VIDEO_ANGLE_HOME_DOWN);
- mRecorder.setRenderRotation(TXLiveConstants.RENDER_ROTATION_PORTRAIT);
- mRecordSpeed = TXRecordCommon.RECORD_SPEED_NORMAL;
- mRecorder.setRecordSpeed(mRecordSpeed);
- mRecorder.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_9_16);
- mCustomConfig = new TXRecordCommon.TXUGCCustomConfig();
- mCustomConfig.videoResolution = TXRecordCommon.VIDEO_RESOLUTION_1080_1920;
- mCustomConfig.minDuration = MIN_DURATION;
- mCustomConfig.maxDuration = MAX_DURATION;
- mCustomConfig.videoBitrate = 6500;
- mCustomConfig.videoGop = 3;
- mCustomConfig.videoFps = 20;
- mCustomConfig.isFront = mFrontCamera;
- mRecorder.setVideoRecordListener(this);
- }
-
-
- /**
- * 初始化萌颜
- */
- private void initBeauty() {
- try {
- mTiSDKManager = new TiSDKManagerBuilder().build();
- mTiSDKManager.setBeautyEnable(true);
- mTiSDKManager.setFaceTrimEnable(true);
- if (mFristInitBeauty) {
- mFristInitBeauty = false;
- ConfigBean configBean = CommonAppConfig.getInstance().getConfig();
- if (configBean != null) {
- mMeibai = configBean.getBeautyMeiBai();//美白
- mMoPi = configBean.getBeautyMoPi();//磨皮
- mBaoHe = configBean.getBeautyBaoHe();//饱和
- mFengNen = configBean.getBeautyFenNen();//粉嫩
- mBigEye = configBean.getBeautyBigEye();//大眼
- mFace = configBean.getBeautyFace();//瘦脸
- mFaceNarrowing = configBean.getBeautyFaceNarrowing();//窄脸
- }
- }
- mTiSDKManager.setSkinWhitening(mMeibai);//美白
- mTiSDKManager.setSkinBlemishRemoval(mMoPi);//磨皮
- mTiSDKManager.setSkinSaturation(mBaoHe);//饱和
- mTiSDKManager.setSkinTenderness(mFengNen);//粉嫩
- mTiSDKManager.setEyeMagnifying(mBigEye);//大眼
- mTiSDKManager.setChinSlimming(mFace);//瘦脸
- mTiSDKManager.setFaceNarrowing(mFaceNarrowing);//窄脸
- mTiSDKManager.setSticker(mTieZhi);//贴纸
- mTiSDKManager.setFilterEnum(mTiFilterEnum);//滤镜
- mTiSDKManager.setDistortionEnum(mTiDistortionEnum);//哈哈镜
-
- } catch (Exception e) {
- ToastUtil.show(R.string.beauty_init_error);
- }
- }
-
- /**
- * 录制回调
- */
- @Override
- public void onRecordEvent(int event, Bundle bundle) {
- if (event == TXRecordCommon.EVT_ID_PAUSE) {
- if (mRecordProgressView != null) {
- mRecordProgressView.clipComplete();
- }
- } else if (event == TXRecordCommon.EVT_CAMERA_CANNOT_USE) {
- ToastUtil.show(R.string.video_record_camera_failed);
- } else if (event == TXRecordCommon.EVT_MIC_CANNOT_USE) {
- ToastUtil.show(R.string.video_record_audio_failed);
- }
- }
-
- /**
- * 录制回调 录制进度
- */
- @Override
- public void onRecordProgress(long milliSecond) {
- if (mRecordProgressView != null) {
- mRecordProgressView.setProgress((int) milliSecond);
- }
- if (mTime != null) {
- mTime.setText(String.format("%.2f", milliSecond / 1000f) + "s");
- }
- mRecordTime = milliSecond;
- if (milliSecond >= MIN_DURATION) {
- if (mBtnNext != null && mBtnNext.getVisibility() != View.VISIBLE) {
- mBtnNext.setVisibility(View.VISIBLE);
- }
- }
- if (milliSecond >= MAX_DURATION) {
- if (!mIsReachMaxRecordDuration) {
- mIsReachMaxRecordDuration = true;
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.cancel();
- }
- showProccessDialog();
- }
- }
- }
-
- /**
- * 录制回调
- */
- @Override
- public void onRecordComplete(TXRecordCommon.TXRecordResult result) {
- hideProccessDialog();
- mRecordStarted = false;
- mRecordStoped = true;
- if (mRecorder != null) {
- mRecorder.toggleTorch(false);
- mRecorder.stopBGM();
- mDuration = mRecorder.getPartsManager().getDuration();
- }
- if (result.retCode < 0) {
- release();
- ToastUtil.show(R.string.video_record_failed);
- } else {
- VideoEditActivity.forward(mContext, mDuration, mVideoPath, true, mHasBgm);
- }
- finish();
- }
-
-
- /**
- * 录制中美颜处理回调
- */
- @Override
- public int onTextureCustomProcess(int i, int i1, int i2) {
- if (mTiSDKManager != null) {
- return mTiSDKManager.renderTexture2D(i, i1, i2, TiRotation.CLOCKWISE_ROTATION_0, false);
- }
- return 0;
- }
-
- /**
- * 录制中美颜处理回调
- */
- @Override
- public void onDetectFacePoints(float[] floats) {
-
- }
-
- /**
- * 录制中美颜处理回调
- */
- @Override
- public void onTextureDestroyed() {
-
- }
-
- public void recordClick(View v) {
- if (mRecordStoped || !canClick()) {
- return;
- }
- int i = v.getId();
- if (i == R.id.btn_start_record) {
- clickRecord();
-
- } else if (i == R.id.btn_camera) {
- clickCamera();
-
- } else if (i == R.id.btn_flash) {
- clickFlash();
-
- } else if (i == R.id.btn_beauty) {
- clickBeauty();
-
- } else if (i == R.id.btn_music) {
- clickMusic();
-
- } else if (i == R.id.btn_speed_1) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_SLOWEST);
-
- } else if (i == R.id.btn_speed_2) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_SLOW);
-
- } else if (i == R.id.btn_speed_3) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_NORMAL);
-
- } else if (i == R.id.btn_speed_4) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_FAST);
-
- } else if (i == R.id.btn_speed_5) {
- changeRecordSpeed(TXRecordCommon.RECORD_SPEED_FASTEST);
-
- } else if (i == R.id.btn_upload) {
- clickUpload();
-
- } else if (i == R.id.btn_delete) {
- clickDelete();
-
- } else if (i == R.id.btn_next) {
- clickNext();
-
- }
- }
-
- /**
- * 点击摄像头
- */
- private void clickCamera() {
- if (mRecorder != null) {
- if (mBtnFlash != null && mBtnFlash.isChecked()) {
- mBtnFlash.doToggle();
- mRecorder.toggleTorch(mBtnFlash.isChecked());
- }
- mFrontCamera = !mFrontCamera;
- mRecorder.switchCamera(mFrontCamera);
- }
- }
-
- /**
- * 点击闪光灯
- */
- private void clickFlash() {
- if (mFrontCamera) {
- ToastUtil.show(R.string.live_open_flash);
- return;
- }
- if (mBtnFlash != null) {
- mBtnFlash.doToggle();
- if (mRecorder != null) {
- mRecorder.toggleTorch(mBtnFlash.isChecked());
- }
- }
- }
-
- /**
- * 点击美颜
- */
- private void clickBeauty() {
- if (mBeautyViewHolder == null) {
- if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
- mBeautyViewHolder = new TiBeautyViewHolder(mContext, mRoot);
- } else {
- mBeautyViewHolder = new DefaultBeautyViewHolder(mContext, mRoot);
- }
-
-// if ("2".equals(mBeautySdkType)) {
-// mBeautyViewHolder = new TiBeautyViewHolder(mContext, mRoot);
-// } else if ("3".equals(mBeautySdkType)){
-// mBeautyViewHolder = new Beauty360ViewHolder(this, mRoot);
-// }else {
-// mBeautyViewHolder = new DefaultBeautyViewHolder(mContext, mRoot);
-// }
-
-
- mBeautyViewHolder.setVisibleListener(new DefaultBeautyViewHolder.VisibleListener() {
- @Override
- public void onVisibleChanged(boolean visible) {
- if (mGroup1 != null) {
- if (visible) {
- if (mGroup1.getVisibility() == View.VISIBLE) {
- mGroup1.setVisibility(View.INVISIBLE);
- }
- } else {
- if (mGroup1.getVisibility() != View.VISIBLE) {
- mGroup1.setVisibility(View.VISIBLE);
- }
- }
- }
- }
- });
-
-
-
- if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
- mBeautyViewHolder.setEffectListener(this);//萌颜
- } else {
- mBeautyViewHolder.setEffectListener(mBaseBeautyEffectListener);//基础美颜
- }
-
-// if ("2".equals(mBeautySdkType)) {
-// mBeautyViewHolder.setEffectListener(this);//萌颜
-// } else if ("3".equals(mBeautySdkType)){
-// mBeautyViewHolder.setEffectListener(mBeauty360EffectListener);//360美颜
-// }else {
-// mBeautyViewHolder.setEffectListener(mBaseBeautyEffectListener);//基础美颜
-// }
-
- }
- mBeautyViewHolder.show();
- }
-
- private Beauty360EffectListener mBeauty360EffectListener = new Beauty360EffectListener() {
-
- @Override
- public void onFilterChanged(String filtertype) {
-
- }
-
- @Override
- public void onFilterStrength(int filterValue) {
-
- }
-
- @Override
- public void onMeiBaiChanged(int progress) {
-
- }
-
- @Override
- public void onSkinsoftStrengthChanged(int progress) {
-
- }
-
- @Override
- public void onHongRunChanged(int progress) {
-
- }
-
- @Override
- public void onFengNenChanged(int progress) {
-
- }
-
- @Override
- public void onBigEyeChanged(int progress) {
-
- }
-
- @Override
- public void onFaceChanged(int progress) {
-
- }
-
- @Override
- public void onTieZhiChanged(String tieZhiName) {
-
- }
-
- @Override
- public void onHaHaChanged(TiDistortionEnum tiDistortionEnum) {
-
- }
-
- @Override
- public void onRockChanged(TiRockEnum tiRockEnum) {
-
- }
-
- @Override
- public void onFaceNarrowing(int progress) {
-
- }
- };
- //基础美颜的回调 (非萌颜)
- private DefaultBeautyEffectListener mBaseBeautyEffectListener = new DefaultBeautyEffectListener() {
- @Override
- public void onFilterChanged(FilterBean filterBean) {
- if (mFilterBitmap != null) {
- mFilterBitmap.recycle();
- }
- if (mRecorder != null) {
- int filterSrc = filterBean.getFilterSrc();
- if (filterSrc != 0) {
- Bitmap bitmap = BitmapUtil.getInstance().decodeBitmap(filterSrc);
- if (bitmap != null) {
- mFilterBitmap = bitmap;
- mRecorder.setFilter(bitmap);
- } else {
- mRecorder.setFilter(null);
- }
- } else {
- mRecorder.setFilter(null);
- }
- }
- }
-
- @Override
- public void onMeiBaiChanged(int progress) {
- if (mRecorder != null) {
- int v = progress / 10;
- if (mMeibai != v) {
- mMeibai = v;
- mRecorder.setBeautyDepth(0, mMoPi, mMeibai, mFengNen);
- }
- }
-
- }
-
- @Override
- public void onMoPiChanged(int progress) {
- if (mRecorder != null) {
- int v = progress / 10;
- if (mMoPi != v) {
- mMoPi = v;
- mRecorder.setBeautyDepth(0, mMoPi, mMeibai, mFengNen);
- }
- }
- }
-
- @Override
- public void onHongRunChanged(int progress) {
- if (mRecorder != null) {
- int v = progress / 10;
- if (mFengNen != v) {
- mFengNen = v;
- mRecorder.setBeautyDepth(0, mMoPi, mMeibai, mFengNen);
- }
- }
- }
- };
-
- /**
- * 点击音乐
- */
- private void clickMusic() {
- if (mVideoMusicViewHolder == null) {
- mVideoMusicViewHolder = new VideoMusicViewHolder(mContext, mRoot);
- mVideoMusicViewHolder.setActionListener(new VideoMusicViewHolder.ActionListener() {
- @Override
- public void onChooseMusic(MusicBean musicBean) {
- mMusicBean = musicBean;
- mBgmPlayStarted = false;
- }
- });
- mVideoMusicViewHolder.addToParent();
- mVideoMusicViewHolder.subscribeActivityLifeCycle();
- }
- mVideoMusicViewHolder.show();
- }
-
- /**
- * 点击上传,选择本地视频
- */
- private void clickUpload() {
- Intent intent = new Intent(mContext, VideoChooseActivity.class);
- intent.putExtra(Constants.VIDEO_DURATION, MAX_DURATION);
- startActivityForResult(intent, 0);
- }
-
- /**
- * 选择本地视频的回调
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == 0 && resultCode == RESULT_OK) {
- mVideoPath = data.getStringExtra(Constants.VIDEO_PATH);
- mDuration = data.getLongExtra(Constants.VIDEO_DURATION, 0);
- VideoEditActivity.forward(mContext, mDuration, mVideoPath, false, false);
- finish();
- }
- }
-
-
- /**
- * 开始预览
- */
- private void startCameraPreview() {
- if (mRecorder != null && mCustomConfig != null && mVideoView != null) {
- mRecorder.startCameraCustomPreview(mCustomConfig, mVideoView);
- if (!mFrontCamera) {
- mRecorder.switchCamera(false);
- }
-
-
- if (CommonAppConfig.getInstance().isTiBeautyEnable()) {
- initBeauty();
- mRecorder.setVideoProcessListener(this);
- }
-
-// if ("2".equals(mBeautySdkType)) {
-// initBeauty();
-// mRecorder.setVideoProcessListener(this);
-// } else if ("3".equals(mBeautySdkType)){
-//
-// }else {
-//
-// }
- }
- }
-
- /**
- * 停止预览
- */
- private void stopCameraPreview() {
- if (mRecorder != null) {
- if (mRecording) {
- pauseRecord();
- }
- mRecorder.stopCameraPreview();
- mRecorder.setVideoProcessListener(null);
- if (mTiSDKManager != null) {
- mTiSDKManager.destroy();
- }
- mTiSDKManager = null;
- }
- }
-
- /**
- * 点击录制
- */
- private void clickRecord() {
- if (mRecordStarted) {
- if (mRecording) {
- pauseRecord();
- } else {
- resumeRecord();
- }
- } else {
- startRecord();
- }
- }
-
- /**
- * 开始录制
- */
- private void startRecord() {
- if (mRecorder != null) {
- mVideoPath = StringUtil.generateVideoOutputPath();//视频保存的路径
- int result = mRecorder.startRecord(mVideoPath, CommonAppConfig.VIDEO_RECORD_TEMP_PATH, null);//为空表示不需要生成视频封面
- if (result != TXRecordCommon.START_RECORD_OK) {
- if (result == TXRecordCommon.START_RECORD_ERR_NOT_INIT) {
- ToastUtil.show(R.string.video_record_tip_1);
- } else if (result == TXRecordCommon.START_RECORD_ERR_IS_IN_RECORDING) {
- ToastUtil.show(R.string.video_record_tip_2);
- } else if (result == TXRecordCommon.START_RECORD_ERR_VIDEO_PATH_IS_EMPTY) {
- ToastUtil.show(R.string.video_record_tip_3);
- } else if (result == TXRecordCommon.START_RECORD_ERR_API_IS_LOWER_THAN_18) {
- ToastUtil.show(R.string.video_record_tip_4);
- } else if (result == TXRecordCommon.START_RECORD_ERR_LICENCE_VERIFICATION_FAILED) {
- ToastUtil.show(R.string.video_record_tip_5);
- }
- return;
- }
- }
- mRecordStarted = true;
- mRecording = true;
- resumeBgm();
- startRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() == View.VISIBLE) {
- mGroup2.setVisibility(View.INVISIBLE);
- }
- }
-
-
- /**
- * 暂停录制
- */
- private void pauseRecord() {
- if (mRecorder == null) {
- return;
- }
- pauseBgm();
- mRecorder.pauseRecord();
- mRecording = false;
- stopRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() != View.VISIBLE) {
- mGroup2.setVisibility(View.VISIBLE);
- }
- TXUGCPartsManager partsManager = mRecorder.getPartsManager();
- if (partsManager != null) {
- List partList = partsManager.getPartsPathList();
- if (partList != null && partList.size() > 0) {
- if (mGroup3 != null && mGroup3.getVisibility() == View.VISIBLE) {
- mGroup3.setVisibility(View.INVISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() != View.VISIBLE) {
- mGroup4.setVisibility(View.VISIBLE);
- }
- } else {
- if (mGroup3 != null && mGroup3.getVisibility() != View.VISIBLE) {
- mGroup3.setVisibility(View.VISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() == View.VISIBLE) {
- mGroup4.setVisibility(View.INVISIBLE);
- }
- }
- }
- }
-
- /**
- * 恢复录制
- */
- private void resumeRecord() {
- if (mRecorder != null) {
- int startResult = mRecorder.resumeRecord();
- if (startResult != TXRecordCommon.START_RECORD_OK) {
- ToastUtil.show(WordUtil.getString(R.string.video_record_failed));
- return;
- }
- }
- mRecording = true;
- resumeBgm();
- startRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() == View.VISIBLE) {
- mGroup2.setVisibility(View.INVISIBLE);
- }
- }
-
- /**
- * 暂停背景音乐
- */
- private void pauseBgm() {
- if (mRecorder != null) {
- mRecorder.pauseBGM();
- }
- }
-
- /**
- * 恢复背景音乐
- */
- private void resumeBgm() {
- if (mRecorder == null) {
- return;
- }
- if (!mBgmPlayStarted) {
- if (mMusicBean == null) {
- return;
- }
- int bgmDuration = mRecorder.setBGM(mMusicBean.getLocalPath());
- mRecorder.playBGMFromTime(0, bgmDuration);
- mRecorder.setBGMVolume(1);//背景音为1最大
- mRecorder.setMicVolume(0);//原声音为0
- mBgmPlayStarted = true;
- mHasBgm = true;
- } else {
- mRecorder.resumeBGM();
- }
- }
-
- /**
- * 按钮录制动画开始
- */
- private void startRecordBtnAnim() {
- if (mRecordView != null) {
- mRecordView.setBackground(mRecordDrawable);
- }
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.start();
- }
- }
-
- /**
- * 按钮录制动画停止
- */
- private void stopRecordBtnAnim() {
- if (mRecordView != null) {
- mRecordView.setBackground(mUnRecordDrawable);
- }
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.cancel();
- }
- if (mVideoRecordBtnView != null) {
- mVideoRecordBtnView.reset();
- }
- }
-
- /**
- * 调整录制速度
- */
- private void changeRecordSpeed(int speed) {
- if (mRecordSpeed == speed) {
- return;
- }
- mRecordSpeed = speed;
- if (mRecorder != null) {
- mRecorder.setRecordSpeed(speed);
- }
- }
-
- /**
- * 删除录制分段
- */
- private void clickDelete() {
- DialogUitl.showSimpleDialog(mContext, WordUtil.getString(R.string.video_record_delete_last), new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- doClickDelete();
- }
- });
- }
-
- /**
- * 删除录制分段
- */
- private void doClickDelete() {
- if (!mRecordStarted || mRecording || mRecorder == null) {
- return;
- }
- TXUGCPartsManager partsManager = mRecorder.getPartsManager();
- if (partsManager == null) {
- return;
- }
- List partList = partsManager.getPartsPathList();
- if (partList == null || partList.size() == 0) {
- return;
- }
- partsManager.deleteLastPart();
- int time = partsManager.getDuration();
- if (mTime != null) {
- mTime.setText(String.format("%.2f", time / 1000f) + "s");
- }
- mRecordTime = time;
- if (time < MIN_DURATION && mBtnNext != null && mBtnNext.getVisibility() == View.VISIBLE) {
- mBtnNext.setVisibility(View.INVISIBLE);
- }
- if (mRecordProgressView != null) {
- mRecordProgressView.deleteLast();
- }
- partList = partsManager.getPartsPathList();
- if (partList != null && partList.size() == 0) {
- if (mGroup2 != null && mGroup2.getVisibility() != View.VISIBLE) {
- mGroup2.setVisibility(View.VISIBLE);
- }
- if (mGroup3 != null && mGroup3.getVisibility() != View.VISIBLE) {
- mGroup3.setVisibility(View.VISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() == View.VISIBLE) {
- mGroup4.setVisibility(View.INVISIBLE);
- }
- }
- }
-
- /**
- * 结束录制,会触发 onRecordComplete
- */
- public void clickNext() {
- stopRecordBtnAnim();
- if (mRecorder != null) {
- mRecorder.stopBGM();
- mRecorder.stopRecord();
- showProccessDialog();
- }
- }
-
-
- /**
- * 录制结束时候显示处理中的弹窗
- */
- private void showProccessDialog() {
- if (mStopRecordDialog == null) {
- mStopRecordDialog = DialogUitl.loadingDialog(mContext, WordUtil.getString(R.string.video_processing));
- mStopRecordDialog.show();
- }
- }
-
- /**
- * 隐藏处理中的弹窗
- */
- private void hideProccessDialog() {
- if (mStopRecordDialog != null) {
- mStopRecordDialog.dismiss();
- }
- mStopRecordDialog = null;
- }
-
-
- @Override
- public void onBackPressed() {
- if (!canClick()) {
- return;
- }
- if (mBeautyViewHolder != null && mBeautyViewHolder.isShowed()) {
- mBeautyViewHolder.hide();
- return;
- }
- if (mVideoMusicViewHolder != null && mVideoMusicViewHolder.isShowed()) {
- mVideoMusicViewHolder.hide();
- return;
- }
- List list = new ArrayList<>();
- if (mRecordTime > 0) {
- list.add(R.string.video_re_record);
- }
- list.add(R.string.video_exit);
- DialogUitl.showStringArrayDialog(mContext, list.toArray(new Integer[list.size()]), new DialogUitl.StringArrayDialogCallback() {
- @Override
- public void onItemClick(String text, int tag) {
- if (tag == R.string.video_re_record) {
- reRecord();
- } else if (tag == R.string.video_exit) {
- exit();
- }
- }
- });
- }
-
- /**
- * 重新录制
- */
- private void reRecord() {
- if (mRecorder == null) {
- return;
- }
- mRecorder.pauseBGM();
- mMusicBean = null;
- mHasBgm = false;
- mBgmPlayStarted = false;
- mRecorder.pauseRecord();
- mRecording = false;
- stopRecordBtnAnim();
- if (mGroup2 != null && mGroup2.getVisibility() != View.VISIBLE) {
- mGroup2.setVisibility(View.VISIBLE);
- }
- TXUGCPartsManager partsManager = mRecorder.getPartsManager();
- if (partsManager != null) {
- partsManager.deleteAllParts();
- }
- mRecorder.onDeleteAllParts();
- if (mTime != null) {
- mTime.setText("0.00s");
- }
- mRecordTime = 0;
- if (mBtnNext != null && mBtnNext.getVisibility() == View.VISIBLE) {
- mBtnNext.setVisibility(View.INVISIBLE);
- }
- if (mRecordProgressView != null) {
- mRecordProgressView.deleteAll();
- }
- if (mGroup3 != null && mGroup3.getVisibility() != View.VISIBLE) {
- mGroup3.setVisibility(View.VISIBLE);
- }
- if (mGroup4 != null && mGroup4.getVisibility() == View.VISIBLE) {
- mGroup4.setVisibility(View.INVISIBLE);
- }
-
- }
-
- /**
- * 退出
- */
- private void exit() {
- release();
- super.onBackPressed();
- }
-
-
- @Override
- protected void onStart() {
- super.onStart();
- startCameraPreview();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- stopCameraPreview();
- if (mRecorder != null && mBtnFlash != null && mBtnFlash.isChecked()) {
- mBtnFlash.doToggle();
- mRecorder.toggleTorch(mBtnFlash.isChecked());
- }
- }
-
- @Override
- protected void onDestroy() {
- release();
- super.onDestroy();
- L.e(TAG, "-------->onDestroy");
- }
-
-
- private void release() {
- if (mStopRecordDialog != null && mStopRecordDialog.isShowing()) {
- mStopRecordDialog.dismiss();
- }
- if (mBeautyViewHolder != null) {
- mBeautyViewHolder.release();
- }
- if (mVideoMusicViewHolder != null) {
- mVideoMusicViewHolder.release();
- }
- if (mRecordProgressView != null) {
- mRecordProgressView.release();
- }
- if (mRecordBtnAnimator != null) {
- mRecordBtnAnimator.cancel();
- }
- if (mRecorder != null) {
- mRecorder.toggleTorch(false);
- mRecorder.stopBGM();
- if (mRecordStarted) {
- mRecorder.stopRecord();
- }
- mRecorder.stopCameraPreview();
- mRecorder.setVideoProcessListener(null);
- mRecorder.setVideoRecordListener(null);
- TXUGCPartsManager getPartsManager = mRecorder.getPartsManager();
- if (getPartsManager != null) {
- getPartsManager.deleteAllParts();
- }
- mRecorder.release();
- }
- if (mTiSDKManager != null) {
- mTiSDKManager.destroy();
- }
- mStopRecordDialog = null;
- mBeautyViewHolder = null;
- mVideoMusicViewHolder = null;
- mRecordProgressView = null;
- mRecordBtnAnimator = null;
- mRecorder = null;
- mTiSDKManager = null;
-
- }
-
-
- /****************美颜回调 start********************/
- /**
- * 设置滤镜回调
- */
- @Override
- public void onFilterChanged(TiFilterEnum tiFilterEnum) {
- if (mTiSDKManager != null) {
- mTiFilterEnum = tiFilterEnum;
- mTiSDKManager.setFilterEnum(tiFilterEnum);
- }
- }
-
- /**
- * 设置美白回调
- */
- @Override
- public void onMeiBaiChanged(int progress) {
- if (mTiSDKManager != null) {
- mMeibai = progress;
- mTiSDKManager.setSkinWhitening(progress);
- }
- }
-
- /**
- * 设置磨皮回调
- */
- @Override
- public void onMoPiChanged(int progress) {
- if (mTiSDKManager != null) {
- mMoPi = progress;
- mTiSDKManager.setSkinBlemishRemoval(progress);
- }
- }
-
- /**
- * 设置饱和回调
- */
- @Override
- public void onBaoHeChanged(int progress) {
- if (mTiSDKManager != null) {
- mBaoHe = progress;
- mTiSDKManager.setSkinSaturation(progress);
- }
- }
-
- /**
- * 设置粉嫩回调
- */
- @Override
- public void onFengNenChanged(int progress) {
- if (mTiSDKManager != null) {
- mFengNen = progress;
- mTiSDKManager.setSkinTenderness(progress);
- }
- }
-
- /**
- * 设置大眼回调
- */
- @Override
- public void onBigEyeChanged(int progress) {
- if (mTiSDKManager != null) {
- mBigEye = progress;
- mTiSDKManager.setEyeMagnifying(progress);
- }
- }
-
- /**
- * 设置瘦脸回调
- */
- @Override
- public void onFaceChanged(int progress) {
- if (mTiSDKManager != null) {
- mFace = progress;
- mTiSDKManager.setChinSlimming(progress);
- }
- }
- /**
- * 设置窄脸回调
- */
- @Override
- public void onFaceNarrowing(int progress) {
- if (mTiSDKManager != null) {
- mFaceNarrowing = progress;
- mTiSDKManager.setFaceNarrowing(progress);
- }
- }
- /**
- * 设置贴纸回调
- */
- @Override
- public void onTieZhiChanged(String tieZhiName) {
- if (mTiSDKManager != null) {
- mTieZhi = tieZhiName;
- mTiSDKManager.setSticker(tieZhiName);
- }
- }
-
- /**
- * 设置哈哈镜回调
- */
- @Override
- public void onHaHaChanged(TiDistortionEnum tiDistortionEnum) {
- if (mTiSDKManager != null) {
- mTiDistortionEnum = tiDistortionEnum;
- mTiSDKManager.setDistortionEnum(tiDistortionEnum);
- }
- }
-
- /**
- * 设置抖动回调
- */
- @Override
- public void onRockChanged(TiRockEnum tiRockEnum) {
- if (mTiSDKManager != null) {
- mTiRockEnum = tiRockEnum;
- mTiSDKManager.setRockEnum(tiRockEnum);
- }
- }
-
-}
diff --git a/video/src/main/java/com/yunbao/video/views/VideoEditFilterViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoEditFilterViewHolder.java
index c0d86f0b7..8269a428d 100644
--- a/video/src/main/java/com/yunbao/video/views/VideoEditFilterViewHolder.java
+++ b/video/src/main/java/com/yunbao/video/views/VideoEditFilterViewHolder.java
@@ -7,10 +7,8 @@ import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
-import com.yunbao.beauty.bean.FilterBean;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.video.R;
-import com.yunbao.beauty.adapter.FilterAdapter;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.BitmapUtil;
@@ -19,7 +17,7 @@ import com.yunbao.common.utils.BitmapUtil;
* 视频编辑 滤镜
*/
-public class VideoEditFilterViewHolder extends AbsViewHolder implements OnItemClickListener, View.OnClickListener {
+public class VideoEditFilterViewHolder extends AbsViewHolder {
private ActionListener mActionListener;
private boolean mShowed;
@@ -37,35 +35,12 @@ public class VideoEditFilterViewHolder extends AbsViewHolder implements OnItemCl
@Override
public void init() {
- findViewById(R.id.root).setOnClickListener(this);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
- FilterAdapter adapter = new FilterAdapter(mContext);
- adapter.setOnItemClickListener(this);
- recyclerView.setAdapter(adapter);
+
}
- @Override
- public void onItemClick(FilterBean bean, int position) {
- if (mBitmap != null) {
- mBitmap.recycle();
- }
- if (mActionListener != null) {
- int filterSrc = bean.getFilterSrc();
- if (filterSrc != 0) {
- Bitmap bitmap = BitmapUtil.getInstance().decodeBitmap(filterSrc);
- if (bitmap != null) {
- mBitmap = bitmap;
- mActionListener.onFilterChanged(bitmap);
- } else {
- mActionListener.onFilterChanged(null);
- }
- } else {
- mActionListener.onFilterChanged(null);
- }
- }
- }
public void show() {
mShowed = true;
@@ -84,10 +59,6 @@ public class VideoEditFilterViewHolder extends AbsViewHolder implements OnItemCl
}
}
- @Override
- public void onClick(View v) {
- hide();
- }
public interface ActionListener {
void onHide();
diff --git a/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java
index 4f157c1b8..b503acc7c 100644
--- a/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java
+++ b/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java
@@ -5,7 +5,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
-import com.yunbao.beauty.custom.TextSeekBar;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.video.R;
@@ -23,8 +22,6 @@ public class VideoEditMusicViewHolder extends AbsViewHolder implements View.OnCl
private TextView mStartTime;//起始时间
private TextView mEndTime;//结束时间
private RangeSlider mRangeSlider;
- private TextSeekBar mOriginSeekBar;//原声
- private TextSeekBar mBgmSeekBar;//背景音
private TextView mMusicName;//音乐名称
private ActionListener mActionListener;
private boolean mShowed;
@@ -78,28 +75,7 @@ public class VideoEditMusicViewHolder extends AbsViewHolder implements View.OnCl
});
findViewById(R.id.root).setOnClickListener(this);
findViewById(R.id.btn_cancel).setOnClickListener(this);
- mOriginSeekBar = (TextSeekBar) findViewById(R.id.btn_origin);
- mBgmSeekBar = (TextSeekBar) findViewById(R.id.seek_bgm);
- TextSeekBar.OnSeekChangeListener seekChangeListener = new TextSeekBar.OnSeekChangeListener() {
- @Override
- public void onProgressChanged(View v, int progress) {
- if (mActionListener != null) {
- int i = v.getId();
- if (i == R.id.btn_origin) {
- mActionListener.onOriginalVolumeChanged(progress / 100f);
- } else if (i == R.id.seek_bgm) {
- mActionListener.onBgmVolumeChanged(progress / 100f);
- }
- }
- }
- };
- mOriginSeekBar.setOnSeekChangeListener(seekChangeListener);
- mBgmSeekBar.setOnSeekChangeListener(seekChangeListener);
- if (mBgmSeekBar != null) {
- mBgmSeekBar.setProgress(0);
- mBgmSeekBar.setEnabled(false);
- }
if (mCurMusicBean != null) {
setMusicBean(mCurMusicBean);
@@ -120,16 +96,7 @@ public class VideoEditMusicViewHolder extends AbsViewHolder implements View.OnCl
mMusicName.setText(bean.getTitle());
}
//如果在录制的时候有背景音,则要把原声禁用
- if (mHasOriginBgm) {
- if (mOriginSeekBar != null) {
- mOriginSeekBar.setEnabled(false);
- mOriginSeekBar.setProgress(0);
- }
- }
- if (mBgmSeekBar != null) {
- mBgmSeekBar.setProgress(80);
- mBgmSeekBar.setEnabled(true);
- }
+
if (mRangeSlider != null) {
mRangeSlider.resetRangePos();
}
@@ -144,14 +111,7 @@ public class VideoEditMusicViewHolder extends AbsViewHolder implements View.OnCl
if (mCutGroup != null && mCutGroup.getVisibility() == View.VISIBLE) {
mCutGroup.setVisibility(View.GONE);
}
- if (mOriginSeekBar != null) {
- mOriginSeekBar.setProgress(80);
- mOriginSeekBar.setEnabled(true);
- }
- if (mBgmSeekBar != null) {
- mBgmSeekBar.setProgress(0);
- mBgmSeekBar.setEnabled(false);
- }
+
if (mActionListener != null) {
mActionListener.onBgmCancelClick();
}
diff --git a/video/src/main/res/layout/activity_video_record.xml b/video/src/main/res/layout/activity_video_record.xml
deleted file mode 100644
index cb0fd8298..000000000
--- a/video/src/main/res/layout/activity_video_record.xml
+++ /dev/null
@@ -1,324 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/video/src/main/res/layout/view_video_edit_volume.xml b/video/src/main/res/layout/view_video_edit_volume.xml
index 48aeb1e05..5d5624579 100644
--- a/video/src/main/res/layout/view_video_edit_volume.xml
+++ b/video/src/main/res/layout/view_video_edit_volume.xml
@@ -115,24 +115,6 @@
/>
-
-
-
-
\ No newline at end of file