|
@@ -4,9 +4,7 @@ import static com.cooleshow.base.common.WebConstants.WEB_URL;
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
-import android.net.Uri;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
-import android.provider.MediaStore;
|
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
@@ -24,17 +22,18 @@ import io.reactivex.rxjava3.functions.Consumer;
|
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
|
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
|
+import com.cooleshow.base.callback.ResultCallback;
|
|
import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.base.service.PlayMusicService;
|
|
import com.cooleshow.base.service.PlayMusicService;
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
import com.cooleshow.base.utils.FileUtils;
|
|
import com.cooleshow.base.utils.FileUtils;
|
|
-import com.cooleshow.base.utils.LogUtils;
|
|
|
|
import com.cooleshow.base.utils.MyFileUtils;
|
|
import com.cooleshow.base.utils.MyFileUtils;
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
import com.cooleshow.base.utils.helper.WebParamsHelper;
|
|
import com.cooleshow.base.utils.helper.WebParamsHelper;
|
|
import com.cooleshow.base.utils.helper.upload.UploadHelper;
|
|
import com.cooleshow.base.utils.helper.upload.UploadHelper;
|
|
import com.cooleshow.student.R;
|
|
import com.cooleshow.student.R;
|
|
import com.cooleshow.student.databinding.ActivityAccompanyBinding;
|
|
import com.cooleshow.student.databinding.ActivityAccompanyBinding;
|
|
|
|
+import com.cooleshow.student.helper.AccompanyHelper;
|
|
import com.cooleshow.student.presenter.web.AccompanyPresenter;
|
|
import com.cooleshow.student.presenter.web.AccompanyPresenter;
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
@@ -64,6 +63,7 @@ import java.util.Locale;
|
|
*/
|
|
*/
|
|
@Route(path = RouterPath.WebCenter.ACTIVITY_ACCOMPANY_HTML)
|
|
@Route(path = RouterPath.WebCenter.ACTIVITY_ACCOMPANY_HTML)
|
|
public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding, AccompanyPresenter> {
|
|
public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding, AccompanyPresenter> {
|
|
|
|
+ public static final String TAG = "AccompanyActivity";
|
|
FrameLayout camera;
|
|
FrameLayout camera;
|
|
FrameLayout fl_webview;
|
|
FrameLayout fl_webview;
|
|
|
|
|
|
@@ -77,6 +77,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
|
|
private String videoDerectoryName = "/cooleshowTaskVideo";
|
|
private String videoDerectoryName = "/cooleshowTaskVideo";
|
|
private View cameraGroupView;
|
|
private View cameraGroupView;
|
|
private String recordVideFilePath; //评测视频
|
|
private String recordVideFilePath; //评测视频
|
|
|
|
+ private String accompanimentUrl; //当前曲子伴奏mp3地址
|
|
private AccompanyFragment accompanyFragment;
|
|
private AccompanyFragment accompanyFragment;
|
|
private JSONObject baseJsonObject;
|
|
private JSONObject baseJsonObject;
|
|
private Intent intentOne;
|
|
private Intent intentOne;
|
|
@@ -164,12 +165,14 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
|
|
try {
|
|
try {
|
|
File file = cameraKitVideo.getVideoFile();
|
|
File file = cameraKitVideo.getVideoFile();
|
|
filePath = file.getPath();
|
|
filePath = file.getPath();
|
|
- saveVideoToGallery(filePath);
|
|
|
|
- hideLoading();
|
|
|
|
- ToastUtil.getInstance().showShort("保存成功");
|
|
|
|
|
|
+ if (!TextUtils.isEmpty(accompanimentUrl)) {
|
|
|
|
+ mixMp3AndMp4(accompanimentUrl, filePath);
|
|
|
|
+ } else {
|
|
|
|
+ handleFileResult(filePath);
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -206,13 +209,12 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
|
|
public void videoUpdate(JSONObject jsonObject) {
|
|
public void videoUpdate(JSONObject jsonObject) {
|
|
baseJsonObject = jsonObject;
|
|
baseJsonObject = jsonObject;
|
|
File file = new File(recordVideFilePath);
|
|
File file = new File(recordVideFilePath);
|
|
-
|
|
|
|
if (!file.exists()) {
|
|
if (!file.exists()) {
|
|
ToastUtil.getInstance().showShort("未找到该视频,请重试");
|
|
ToastUtil.getInstance().showShort("未找到该视频,请重试");
|
|
MyFileUtils.deleteFile(recordVideFilePath);
|
|
MyFileUtils.deleteFile(recordVideFilePath);
|
|
}
|
|
}
|
|
String bucket = WebParamsHelper.getParams(jsonObject, "bucket");
|
|
String bucket = WebParamsHelper.getParams(jsonObject, "bucket");
|
|
- UploadHelper uploadHelper = new UploadHelper(AccompanyActivity.this,bucket);
|
|
|
|
|
|
+ UploadHelper uploadHelper = new UploadHelper(AccompanyActivity.this, bucket);
|
|
uploadHelper.uploadFile(file);
|
|
uploadHelper.uploadFile(file);
|
|
uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
|
|
uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
|
|
@Override
|
|
@Override
|
|
@@ -239,17 +241,22 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void onDownloadAccompaniment(String accompanyUrl) {
|
|
|
|
+ AccompanyActivity.this.accompanimentUrl = accompanyUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 停止录视频
|
|
* 停止录视频
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void endCapture() {
|
|
public void endCapture() {
|
|
|
|
+ showLoading("正在处理视频中");
|
|
if (cameraView != null && cameraView.getVisibility() == View.VISIBLE) {
|
|
if (cameraView != null && cameraView.getVisibility() == View.VISIBLE) {
|
|
new Handler().postDelayed(new Runnable() {
|
|
new Handler().postDelayed(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
cameraView.stopVideo();//结束录像
|
|
cameraView.stopVideo();//结束录像
|
|
-
|
|
|
|
}
|
|
}
|
|
}, 1000);
|
|
}, 1000);
|
|
}
|
|
}
|
|
@@ -265,12 +272,45 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
|
|
startService(intentOne);
|
|
startService(intentOne);
|
|
}
|
|
}
|
|
|
|
|
|
- private void saveVideoToGallery(String filePath){
|
|
|
|
|
|
+ private void mixMp3AndMp4(String accompanimentUrl, String videoPath) {
|
|
|
|
+ AccompanyHelper.getInstance().download(accompanimentUrl, new ResultCallback<String>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(String s) {
|
|
|
|
+ AccompanyHelper.getInstance().startMix(videoPath, s, new ResultCallback<String>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(String s) {
|
|
|
|
+ Log.i(TAG, "混音success:" + s);
|
|
|
|
+ recordVideFilePath = s;
|
|
|
|
+ handleFileResult(s);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(int errorCode, String errorStr) {
|
|
|
|
+ handleFileResult(filePath);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(int errorCode, String errorStr) {
|
|
|
|
+ handleFileResult(filePath);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void handleFileResult(String filePath) {
|
|
|
|
+ hideLoading();
|
|
|
|
+ saveVideoToGallery(filePath);
|
|
|
|
+ ToastUtil.getInstance().showShort("保存成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void saveVideoToGallery(String filePath) {
|
|
Observable.create(new ObservableOnSubscribe<Object>() {
|
|
Observable.create(new ObservableOnSubscribe<Object>() {
|
|
@Override
|
|
@Override
|
|
public void subscribe(@NonNull ObservableEmitter<Object> emitter) throws Throwable {
|
|
public void subscribe(@NonNull ObservableEmitter<Object> emitter) throws Throwable {
|
|
- Log.i("pq","saveVideoToGallery:"+Thread.currentThread().getName());
|
|
|
|
- FileUtils.saveVideoToGallery(AccompanyActivity.this.getApplicationContext(),filePath);
|
|
|
|
|
|
+ Log.i("pq", "saveVideoToGallery:" + Thread.currentThread().getName());
|
|
|
|
+ FileUtils.saveVideoToGallery(AccompanyActivity.this.getApplicationContext(), filePath);
|
|
}
|
|
}
|
|
}).subscribeOn(Schedulers.newThread())
|
|
}).subscribeOn(Schedulers.newThread())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
@@ -389,7 +429,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
|
|
}
|
|
}
|
|
} else if (requestCode == 1011) {
|
|
} else if (requestCode == 1011) {
|
|
String selectAddress = data.getStringExtra("selectAddress");
|
|
String selectAddress = data.getStringExtra("selectAddress");
|
|
- if (null!=accompanyFragment){
|
|
|
|
|
|
+ if (null != accompanyFragment) {
|
|
accompanyFragment.selectAddress(selectAddress);
|
|
accompanyFragment.selectAddress(selectAddress);
|
|
}
|
|
}
|
|
}
|
|
}
|