浏览代码

增加音频合成模块依赖

Pq 1 年之前
父节点
当前提交
6d0c454714
共有 23 个文件被更改,包括 434 次插入232 次删除
  1. 4 0
      BaseLibrary/src/main/java/com/cooleshow/base/common/WebApi.java
  2. 4 3
      BaseLibrary/src/main/java/com/cooleshow/base/recorder/BaseDataRecorder.java
  3. 18 6
      BaseLibrary/src/main/java/com/cooleshow/base/recorder/PullTransport.java
  4. 5 5
      BaseLibrary/src/main/java/com/cooleshow/base/recorder/WavRecorder.java
  5. 4 0
      BaseLibrary/src/main/java/com/cooleshow/base/utils/MyFileUtils.java
  6. 15 8
      ffmpegCmd/src/main/java/com/cooleshow/ffmpegcmd/FFmpegCmd.java
  7. 61 27
      ffmpegCmd/src/main/java/com/cooleshow/ffmpegcmd/util/FFmpegUtil.java
  8. 2 1
      musicMerge/src/main/java/com/cooleshow/musicmerge/helper/MixHelper.java
  9. 4 2
      musicMerge/src/main/java/com/cooleshow/musicmerge/ui/MusicHandleSettingFragment.java
  10. 二进制
      musicMerge/src/main/res/drawable-xhdpi/icon_music_merge_offset_add.png
  11. 二进制
      musicMerge/src/main/res/drawable-xhdpi/icon_music_merge_offset_reduce.png
  12. 二进制
      musicMerge/src/main/res/drawable-xxhdpi/icon_music_merge_offset_add.png
  13. 二进制
      musicMerge/src/main/res/drawable-xxhdpi/icon_music_merge_offset_reduce.png
  14. 8 0
      musicMerge/src/main/res/drawable/shape_434343_to_666666_round.xml
  15. 6 0
      musicMerge/src/main/res/drawable/shape_5e000000_bottom_5dp.xml
  16. 5 0
      musicMerge/src/main/res/drawable/shape_f8f8f8_10dp.xml
  17. 55 13
      student/src/main/java/com/cooleshow/student/ui/web/AccompanyActivity.java
  18. 21 1
      student/src/main/java/com/cooleshow/student/ui/web/AccompanyFragment.java
  19. 9 0
      student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceAccomPanyUtils.java
  20. 1 0
      teacher/build.gradle
  21. 53 37
      teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyActivity.java
  22. 150 129
      teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyFragment.java
  23. 9 0
      teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceAccomPanyUtils.java

+ 4 - 0
BaseLibrary/src/main/java/com/cooleshow/base/common/WebApi.java

@@ -15,4 +15,8 @@ public class WebApi {
     //跟练模式
     public static final String CLOUD_TOGGLE_FOLLOW = "cloudToggleFollow";
     public static final String WITHDRAW_TAG = "WITHDRAW";
+
+    public static final String API_OPEN_ADJUST_RECORDING = "openAdjustRecording";
+
+    public static final String API_SAVE_FILE = "saveFile";
 }

+ 4 - 3
BaseLibrary/src/main/java/com/cooleshow/base/recorder/BaseDataRecorder.java

@@ -8,6 +8,7 @@ import android.media.AudioRecord;
 import android.os.Build;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.concurrent.ExecutorService;
@@ -69,9 +70,9 @@ public class BaseDataRecorder implements Recorder {
 
                 }
             }
-//            if (outputStream == null) {
-//                outputStream = new FileOutputStream(file);
-//            }
+            if (outputStream == null) {
+                outputStream = new FileOutputStream(file);
+            }
             audioRecord.startRecording();
             pullTransport.isEnableToBePulled(true);
             pullTransport.startPoolingAndWriting(audioRecord, bufferSizeInBytes, outputStream);

+ 18 - 6
BaseLibrary/src/main/java/com/cooleshow/base/recorder/PullTransport.java

@@ -93,12 +93,24 @@ public interface PullTransport {
             Log.d("接收音频数据", "startPoolingAndWriting() called with: audioRecord = [" + audioRecord + "], pullSizeInBytes = [" + pullSizeInBytes + "], outputStream = [" + outputStream + "]");
             Log.i("接收音频数据", "startPoolingAndWriting byte: " +  new byte[pullSizeInBytes]);
             AudioChunk audioChunk = new AudioChunk.Bytes(new byte[pullSizeInBytes]);
-            while (pull) {
-                int count = audioRecord.read(audioChunk.toBytes(), 0, pullSizeInBytes);
-                if (AudioRecord.ERROR_INVALID_OPERATION != count && AudioRecord.ERROR_BAD_VALUE != count) {
-                    postPullEvent(audioChunk);// 推送原始音频数据块
-                    Log.i("接收音频数据", "startPoolingAndWriting: " +  audioChunk.toBytes().toString());
-//                    outputStream.write(audioChunk.toBytes());// 将数据写入文件
+            try {
+                while (pull) {
+                    int count = audioRecord.read(audioChunk.toBytes(), 0, pullSizeInBytes);
+                    if (AudioRecord.ERROR_INVALID_OPERATION != count && AudioRecord.ERROR_BAD_VALUE != count) {
+                        postPullEvent(audioChunk);// 推送原始音频数据块
+                        Log.i("接收音频数据", "startPoolingAndWriting: " + audioChunk.toBytes().toString());
+                        outputStream.write(audioChunk.toBytes());// 将数据写入文件
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (outputStream != null) {
+                    try {
+                        outputStream.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
                 }
             }
         }

+ 5 - 5
BaseLibrary/src/main/java/com/cooleshow/base/recorder/WavRecorder.java

@@ -26,12 +26,12 @@ public class WavRecorder extends BaseDataRecorder {
 
     @Override
     public void stopRecording() {
-//        try {
+        try {
             super.stopRecording();
-//            writeWavHeader();
-//        } catch (IOException e) {
-//            throw new RuntimeException("Error in applying wav header", e);
-//        }
+            writeWavHeader();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     /**

+ 4 - 0
BaseLibrary/src/main/java/com/cooleshow/base/utils/MyFileUtils.java

@@ -1656,6 +1656,10 @@ public class MyFileUtils {
         return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
     }
 
+    public static String getRecordFilePath() {
+        return getCacheDir(Utils.getApp()) + File.separator + "wav-accompany" + ".wav";
+    }
+
     public static boolean isVideo(String filePath) {
         File file = new File(filePath);
         if (!file.exists()) {

+ 15 - 8
ffmpegCmd/src/main/java/com/cooleshow/ffmpegcmd/FFmpegCmd.java

@@ -3,8 +3,6 @@ package com.cooleshow.ffmpegcmd;
 import android.text.TextUtils;
 import android.util.Log;
 
-import androidx.annotation.IntDef;
-
 import com.cooleshow.ffmpegcmd.listener.OnHandleListener;
 import com.cooleshow.ffmpegcmd.util.ThreadPoolUtil;
 
@@ -13,6 +11,8 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.List;
 
+import androidx.annotation.IntDef;
+
 /**
  * The JNI interface of handling FFmpeg command
  * Created by frank on 2018/1/23
@@ -42,11 +42,13 @@ public class FFmpegCmd {
     @Documented
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({STATE_INIT, STATE_RUNNING, STATE_FINISH, STATE_ERROR})
-    public @interface FFmpegState {}
+    public @interface FFmpegState {
+    }
 
     /**
      * Execute FFmpeg command
-     * @param commands the String array of command
+     *
+     * @param commands         the String array of command
      * @param onHandleListener the callback for executing command
      */
     public static void execute(final String[] commands, final OnHandleListener onHandleListener) {
@@ -73,7 +75,8 @@ public class FFmpegCmd {
 
     /**
      * Execute FFmpeg multi commands
-     * @param commands the String array of command
+     *
+     * @param commands         the String array of command
      * @param onHandleListener the callback for executing command
      */
     public static void execute(final List<String[]> commands, final OnHandleListener onHandleListener) {
@@ -89,7 +92,7 @@ public class FFmpegCmd {
                 int count = 0;
                 for (String[] command : commands) {
                     result = handle(command);
-                    count ++;
+                    count++;
                     Log.i(TAG, count + " result=" + result);
                 }
                 if (onHandleListener != null) {
@@ -107,7 +110,7 @@ public class FFmpegCmd {
     /**
      * execute probe cmd internal
      *
-     * @param commands commands
+     * @param commands         commands
      * @param onHandleListener onHandleListener
      */
     public static void executeProbe(final String[] commands, final OnHandleListener onHandleListener) {
@@ -151,7 +154,7 @@ public class FFmpegCmd {
         if (mProgressListener != null) {
             if (position > 0 && duration > 0) {
                 int progress = position * 100 / duration;
-                if (progress < 100) {
+                if (progress <= 100) {
                     mProgressListener.onProgress(progress, duration);
                 }
             } else {
@@ -160,6 +163,10 @@ public class FFmpegCmd {
         }
     }
 
+    public static void setOnProgressCallback(OnHandleListener onProgressCallback) {
+        mProgressListener = onProgressCallback;
+    }
+
     public static void onMsgCallback(String msg, int level) {
         if (msg != null && !msg.isEmpty()) {
             Log.e(TAG, "from native msg=" + msg);

+ 61 - 27
ffmpegCmd/src/main/java/com/cooleshow/ffmpegcmd/util/FFmpegUtil.java

@@ -4,7 +4,6 @@ package com.cooleshow.ffmpegcmd.util;
 import android.content.Context;
 
 import com.cooleshow.ffmpegcmd.model.VideoLayout;
-import com.cooleshow.ffmpegcmd.util.ScreenUtil;
 
 import java.util.List;
 import java.util.Locale;
@@ -116,7 +115,6 @@ public class FFmpegUtil {
 
     /**
      * mix multiple audio inputs into a single output
-     *
      */
     public static String[] mixAudio(String inputPath, String mixPath, String outputPath) {
         //mixing formula: value = sample1 + sample2 - ((sample1 * sample2) >> 0x10)
@@ -144,13 +142,40 @@ public class FFmpegUtil {
         }
         mixAudioCmd[6] = amix;
         if (disableThumb) mixAudioCmd[7] = "-vn";
-        mixAudioCmd[len-1] = outputPath;
+        mixAudioCmd[len - 1] = outputPath;
+        return mixAudioCmd;
+    }
+
+    public static String[] mixAudio(String inputPath, String mixPath, int weight1, int weight2,float volume1,float volume2,
+                                    boolean disableThumb, String outputPath, int delay, int delay2) {
+        //duration: first shortest longest
+        //weight: adjust weight(volume) of each audio stream
+        //disableThumb:(-vn)if not disable, it may cause incorrect mixing
+        int len = 8;
+//        String amix = "[1]adelay=%d|%d[b];[0][b]amix=inputs=2:duration=shortest";
+        String amix = "[0]volume=%f,adelay=%d|%d[a];[1]volume=%f,adelay=%d|%d[b];[a][b]amix=inputs=2:duration=first";
+        amix = String.format(Locale.getDefault(), amix,volume1, delay, delay, volume2,delay2, delay2);
+        if (disableThumb) len += 1;
+        String[] mixAudioCmd = new String[len];
+        mixAudioCmd[0] = "ffmpeg";
+        mixAudioCmd[1] = "-i";
+        mixAudioCmd[2] = inputPath;
+        mixAudioCmd[3] = "-i";
+        mixAudioCmd[4] = mixPath;
+        mixAudioCmd[5] = "-filter_complex";
+        if (weight1 > 0 && weight2 > 0) {
+            String weight = ":weights=" + "'" + weight1 + " " + weight2 + "'";
+            amix += weight;
+        }
+        mixAudioCmd[6] = amix;
+        if (disableThumb) mixAudioCmd[7] = "-vn";
+        mixAudioCmd[len - 1] = outputPath;
         return mixAudioCmd;
     }
 
+
     /**
      * merge multiple audio streams into a single multi-channel stream
-     *
      */
     public static String[] mergeAudio(String inputPath, String mergePath, String outputPath) {
         String mergeCmd = "ffmpeg -i %s -i %s -filter_complex [0:a][1:a]amerge=inputs=2[aout] -map [aout] %s";
@@ -208,7 +233,7 @@ public class FFmpegUtil {
     /**
      * Detect silence of a chunk of audio
      *
-     * @param inputPath  input file
+     * @param inputPath input file
      */
     public static String[] audioSilenceDetect(String inputPath) {
         // silence_start: 268.978
@@ -351,6 +376,7 @@ public class FFmpegUtil {
 
     /**
      * joint every single video together
+     *
      * @param fileListPath the path file list
      * @param outputPath   output path
      * @return joint video success or not
@@ -442,7 +468,7 @@ public class FFmpegUtil {
      * @param outputPath output file
      * @return add watermark success or not
      */
-    public static String[] addWaterMarkGif(Context context,String inputPath, String imgPath, int location, int bitRate,
+    public static String[] addWaterMarkGif(Context context, String inputPath, String imgPath, int location, int bitRate,
                                            int offsetXY, String outputPath) {
         String mBitRate = bitRate + "k";
         int offset = ScreenUtil.INSTANCE.dp2px(context, offsetXY);
@@ -497,11 +523,11 @@ public class FFmpegUtil {
      * @return convert gif success or not
      */
     public static String[] generateGifByPalette(String inputPath, String palette, int startTime, int duration,
-                                           int frameRate, int width, String outputPath) {
+                                                int frameRate, int width, String outputPath) {
         String paletteGifCmd = "ffmpeg -ss %d -accurate_seek -t %d -i -i -lavfi fps=%d,scale=%d:-1:flags=lanczos[x];[x][1:v]" +
                 "paletteuse=dither=bayer:bayer_scale=3";
         paletteGifCmd = String.format(Locale.getDefault(), paletteGifCmd, startTime,
-                                      duration, frameRate, width);
+                duration, frameRate, width);
         return insert(paletteGifCmd.split(" "), 7, inputPath, 9, palette, outputPath);
     }
 
@@ -524,9 +550,9 @@ public class FFmpegUtil {
     /**
      * convert resolution
      *
-     * @param inputPath   input file
-     * @param resolution  resolution
-     * @param outputPath  output file
+     * @param inputPath  input file
+     * @param resolution resolution
+     * @param outputPath output file
      * @return convert success or not
      */
     public static String[] convertResolution(String inputPath, String resolution, String outputPath) {
@@ -677,7 +703,8 @@ public class FFmpegUtil {
 
     /**
      * Change Video from RGB to gray(black & white)
-     * @param inputPath inputPath
+     *
+     * @param inputPath  inputPath
      * @param outputPath outputPath
      * @return grayCmd
      */
@@ -688,13 +715,14 @@ public class FFmpegUtil {
 
     /**
      * Photo zoom to video
-     * @param inputPath inputPath
-     * @param position position
-     *                 0:center
-     *                 1:left to right
-     *                 2:right to left
-     *                 3:down to up
-     *                 4:up to down
+     *
+     * @param inputPath  inputPath
+     * @param position   position
+     *                   0:center
+     *                   1:left to right
+     *                   2:right to left
+     *                   3:down to up
+     *                   4:up to down
      * @param outputPath outputPath
      * @return zoomCmd
      */
@@ -724,7 +752,7 @@ public class FFmpegUtil {
     /**
      * using FFprobe to parse the media format
      *
-     * @param inputPath  inputFile
+     * @param inputPath inputFile
      * @return probe success or not
      */
     public static String[] probeFormat(String inputPath) {
@@ -736,6 +764,7 @@ public class FFmpegUtil {
     /**
      * Changing the speed of playing, speed range at 0.5-2 in audio-video mode.
      * However, in pure video mode, the speed range at 0.25-4
+     *
      * @param inputPath  the inputFile of normal speed
      * @param outputPath the outputFile which you want to change speed
      * @param speed      speed of playing
@@ -754,7 +783,7 @@ public class FFmpegUtil {
                 throw new IllegalArgumentException("speed range is 0.5--2");
             }
         }
-        float ptsFactor = 1/speed;
+        float ptsFactor = 1 / speed;
         String speedCmd;
         if (pureVideo) {
             speedCmd = "ffmpeg -i -filter_complex [0:v]setpts=%.2f*PTS[v] -map [v]";
@@ -768,9 +797,10 @@ public class FFmpegUtil {
 
     /**
      * Changing the speed of playing, speed range at 0.5-2 in audio.
-     * @param inputPath the inputFile of normal speed
+     *
+     * @param inputPath  the inputFile of normal speed
      * @param outputPath the outputFile which you want to change speed
-     * @param speed speed of playing
+     * @param speed      speed of playing
      * @return change speed success or not
      */
     public static String[] changeAudioSpeed(String inputPath, String outputPath, float speed) {
@@ -785,9 +815,10 @@ public class FFmpegUtil {
 
     /**
      * Insert the picture into the header of video, which as a thumbnail
-     * @param inputPath inputFile
+     *
+     * @param inputPath   inputFile
      * @param picturePath the path of thumbnail
-     * @param outputPath targetFile
+     * @param outputPath  targetFile
      * @return command of inserting picture
      */
     public static String[] insertPicIntoVideo(String inputPath, String picturePath, String outputPath) {
@@ -805,8 +836,9 @@ public class FFmpegUtil {
      * After publish the streams, you could use VLC to play it
      * Note: if stream is rtmp protocol, need to start your rtmp server
      * Note: if stream is http protocol, need to start your http server
-     * @param inputPath inputFile
-     * @param duration how long of inputFile you want to publish
+     *
+     * @param inputPath  inputFile
+     * @param duration   how long of inputFile you want to publish
      * @param streamUrl1 the url of stream1
      * @param streamUrl2 the url of stream2
      * @return command of build flv index
@@ -833,6 +865,7 @@ public class FFmpegUtil {
 
     /**
      * Trim one or more segments from a single video
+     *
      * @param inputPath  the path of input file
      * @param start1     start time of the first segment
      * @param end1       end time of the first segment
@@ -860,6 +893,7 @@ public class FFmpegUtil {
 
     /**
      * Convert video into stereo3d mode(VR video)
+     *
      * @param inputPath  inputPath
      * @param outputPath outputPath
      * @return the command of stereo3d

+ 2 - 1
musicMerge/src/main/java/com/cooleshow/musicmerge/helper/MixHelper.java

@@ -10,6 +10,7 @@ import com.cooleshow.base.utils.EncryptUtils;
 import com.cooleshow.base.utils.FileUtils;
 import com.cooleshow.base.utils.LOG;
 import com.cooleshow.base.utils.LogUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.ffmpegcmd.FFmpegCmd;
 import com.cooleshow.ffmpegcmd.listener.OnHandleListener;
@@ -57,7 +58,7 @@ public class MixHelper {
     public static final String onlyVideoPath = BASE_PATH + File.separator + "onlyVideoPath.mp4";
 
     public static String getVoicePath() {
-        return FileUtils.getCacheDir(Utils.getApp()) + File.separator + "wav-accompany" + ".wav";
+        return MyFileUtils.getRecordFilePath();
     }
 
     private MixHelper() {

+ 4 - 2
musicMerge/src/main/java/com/cooleshow/musicmerge/ui/MusicHandleSettingFragment.java

@@ -466,8 +466,10 @@ public class MusicHandleSettingFragment extends BaseFragment<FgMusicHandleSettin
 
     @Override
     public void onDestroy() {
-        removeCallBack(mViewBinding.tvRecordVolumeValue, mRunnable);
-        removeCallBack(mViewBinding.tvAccompanyVolumeValue, mRunnable2);
+        if (mViewBinding != null) {
+            removeCallBack(mViewBinding.tvRecordVolumeValue, mRunnable);
+            removeCallBack(mViewBinding.tvAccompanyVolumeValue, mRunnable2);
+        }
         super.onDestroy();
     }
 

二进制
musicMerge/src/main/res/drawable-xhdpi/icon_music_merge_offset_add.png


二进制
musicMerge/src/main/res/drawable-xhdpi/icon_music_merge_offset_reduce.png


二进制
musicMerge/src/main/res/drawable-xxhdpi/icon_music_merge_offset_add.png


二进制
musicMerge/src/main/res/drawable-xxhdpi/icon_music_merge_offset_reduce.png


+ 8 - 0
musicMerge/src/main/res/drawable/shape_434343_to_666666_round.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+    <gradient android:startColor="#434343"
+        android:angle="270"
+        android:endColor="#666666"/>
+
+</shape>

+ 6 - 0
musicMerge/src/main/res/drawable/shape_5e000000_bottom_5dp.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#5e000000"/>
+    <corners android:bottomRightRadius="8dp"
+        android:bottomLeftRadius="8dp"/>
+</shape>

+ 5 - 0
musicMerge/src/main/res/drawable/shape_f8f8f8_10dp.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#f8f8f8"/>
+    <corners android:radius="10dp"/>
+</shape>

+ 55 - 13
student/src/main/java/com/cooleshow/student/ui/web/AccompanyActivity.java

@@ -24,6 +24,7 @@ import io.reactivex.rxjava3.functions.Consumer;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alibaba.android.arouter.launcher.ARouter;
 import com.cooleshow.base.callback.ResultCallback;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.service.PlayMusicService;
@@ -72,6 +73,8 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
 
     private final int PORTRAIT_REQUEST_CODE = 1002;
     private final int ADD_ACCOMPANIMENT_CODE = 1003;
+
+    private final int SAVE_PRACTICE_REQUEST_CODE = 1004;
     private String authorization;
     private String webViewUrl;
 
@@ -182,11 +185,12 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
                                 }
                                 File file = cameraKitVideo.getVideoFile();
                                 filePath = file.getPath();
-                                if (!TextUtils.isEmpty(accompanimentUrl)) {
-                                    mixMp3AndMp4(accompanimentUrl, filePath);
-                                } else {
-                                    handleFileResult(filePath);
-                                }
+//                                handleFileResult(filePath);
+//                                if (!TextUtils.isEmpty(accompanimentUrl)) {
+//                                    mixMp3AndMp4(accompanimentUrl, filePath);
+//                                } else {
+//                                    handleFileResult(filePath);
+//                                }
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
@@ -201,6 +205,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             @Override
             public void closeCamera() {
                 if (cameraView != null) {
+                    filePath = "";
                     cameraView.stop();
                     cameraView.destroyDrawingCache();
                     camera.removeView(cameraGroupView);
@@ -256,14 +261,11 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             @Override
             public void onDownloadAccompaniment(String accompanyUrl) {
                 AccompanyActivity.this.accompanimentUrl = accompanyUrl;
-                if (TextUtils.isEmpty(accompanimentUrl)) {
-                    runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            ToastUtil.getInstance().showShort("当前曲目无mp3伴奏");
-                        }
-                    });
-                }
+            }
+
+            @Override
+            public void openAdjustRecording(String recordId, String title, String coverImg) {
+                goAdjustMusic(recordId, title, coverImg);
             }
 
             /**
@@ -344,6 +346,24 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
                 });
     }
 
+    private void goAdjustMusic(String recordId, String title, String coverImg) {
+        if (TextUtils.isEmpty(accompanimentUrl)) {
+            return;
+        }
+        String recordFilePath = MyFileUtils.getRecordFilePath();
+        if (!TextUtils.isEmpty(filePath)) {
+            recordFilePath = filePath;
+        }
+        ARouter.getInstance().build(RouterPath.MusicTuner.MUSIC_MERGE_PAGE)
+                .withString("accompanyUrl", accompanimentUrl)
+                .withString("recordFilePath", recordFilePath)
+                .withString("recordId", recordId)
+                .withString("title", title)
+                .withString("coverImg", coverImg)
+                .withInt("c_orientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
+                .navigation(this, SAVE_PRACTICE_REQUEST_CODE);
+    }
+
     private void handleFileResult(String filePath) {
         hideLoading();
         saveVideoToGallery(filePath);
@@ -443,6 +463,16 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
                 }
                 return;
             }
+
+            if (requestCode == SAVE_PRACTICE_REQUEST_CODE) {
+                if (data != null) {
+                    int result = data.getIntExtra("saveWorksStatus", 0);
+                    if (result == 1) {
+                        sendSaveSuccessMsg();
+                    }
+                }
+                return;
+            }
         }
         if (requestCode == ADD_ACCOMPANIMENT_CODE) {
             try {
@@ -479,6 +509,18 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
         }
     }
 
+    private void sendSaveSuccessMsg() {
+        JSONObject json = new JSONObject();
+        try {
+            JSONObject content = new JSONObject();
+            json.put("api", "hideComplexButton");
+            json.put("content", content);
+            accompanyFragment.onSendMessage(json.toString());
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
     @Override
     protected void onStop() {
         if (cameraView != null) {

+ 21 - 1
student/src/main/java/com/cooleshow/student/ui/web/AccompanyFragment.java

@@ -970,7 +970,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
     // 录音文件存储名称
     private String getVoicePath() {
-        return MyFileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
+        return MyFileUtils.getRecordFilePath();
     }
 
     /**
@@ -1464,6 +1464,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
          * @param url
          */
         void onDownloadAccompaniment(String url);
+        void openAdjustRecording(String recordId, String title, String coverImg);
     }
 
     public WebViewListener listener;
@@ -2068,6 +2069,25 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         }
     }
 
+    @Override
+    public void openAdjustRecording(JSONObject message) {
+        if (message != null) {
+            JSONObject contentJson = message.optJSONObject("content");
+            if (contentJson != null) {
+                int recordIdByInt = contentJson.optInt("recordId", -1);
+                String recordId = String.valueOf(recordIdByInt);
+                if (recordIdByInt == -1) {
+                    recordId = contentJson.optString("recordId");
+                }
+                String title = contentJson.optString("title");
+                String coverImg = contentJson.optString("coverImg");
+                if (onAccompanyListener != null) {
+                    onAccompanyListener.openAdjustRecording(recordId, title, coverImg);
+                }
+            }
+        }
+    }
+
     private void handleCloudFollow(String mode) {
         if (mMusicTunerHelper == null) {
             mMusicTunerHelper = new MusicTunerHelper(new MusicTunerHelper.OnEventListener() {

+ 9 - 0
student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceAccomPanyUtils.java

@@ -366,6 +366,13 @@ public class JsInterfaceAccomPanyUtils extends Object {
                     }
                     return;
                 }
+
+                if (TextUtils.equals(WebApi.API_OPEN_ADJUST_RECORDING, api)) {
+                    if (onListener != null) {
+                        onListener.openAdjustRecording(jsonObject);
+                    }
+                    return;
+                }
             } catch (Exception e) {
 
             }
@@ -654,6 +661,8 @@ public class JsInterfaceAccomPanyUtils extends Object {
          * @param url
          */
         void saveAccompanimentMp3(String url);
+
+        void openAdjustRecording(JSONObject jsonObject);
     }
 
 }

+ 1 - 0
teacher/build.gradle

@@ -132,6 +132,7 @@ dependencies {
     implementation project(path: ':chatModule')
     implementation project(path: ':tclive')
     implementation project(path: ':classRoom')
+    implementation project(path: ':musicMerge')
     implementation "com.alibaba:arouter-api:$rootProject.ext.android.arouter_api_version"
     kapt "com.alibaba:arouter-compiler:$rootProject.ext.android.arouter_api_version"
 

+ 53 - 37
teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyActivity.java

@@ -22,6 +22,7 @@ import io.reactivex.rxjava3.functions.Consumer;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alibaba.android.arouter.launcher.ARouter;
 import com.cooleshow.base.callback.ResultCallback;
 import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.router.RouterPath;
@@ -71,6 +72,8 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
 
     private final int PORTRAIT_REQUEST_CODE = 1002;
     private final int ADD_ACCOMPANIMENT_CODE = 1003;
+
+    private final int SAVE_PRACTICE_REQUEST_CODE = 1004;
     private String authorization;
     private String webViewUrl;
 
@@ -182,11 +185,12 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
                                 }
                                 File file = cameraKitVideo.getVideoFile();
                                 filePath = file.getPath();
-                                if (!TextUtils.isEmpty(accompanimentUrl)) {
-                                    mixMp3AndMp4(accompanimentUrl, filePath);
-                                } else {
-                                    handleFileResult(filePath);
-                                }
+//                                handleFileResult(filePath);
+//                                if (!TextUtils.isEmpty(accompanimentUrl)) {
+//                                    mixMp3AndMp4(accompanimentUrl, filePath);
+//                                } else {
+//                                    handleFileResult(filePath);
+//                                }
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
@@ -201,6 +205,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             @Override
             public void closeCamera() {
                 if (cameraView != null) {
+                    filePath = "";
                     cameraView.stop();
                     cameraView.destroyDrawingCache();
                     camera.removeView(cameraGroupView);
@@ -262,14 +267,11 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             @Override
             public void onDownloadAccompaniment(String accompanyUrl) {
                 AccompanyActivity.this.accompanimentUrl = accompanyUrl;
-                if (TextUtils.isEmpty(accompanimentUrl)) {
-                    runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            ToastUtil.getInstance().showShort("当前曲目无mp3伴奏");
-                        }
-                    });
-                }
+            }
+
+            @Override
+            public void openAdjustRecording(String recordId, String title, String coverImg) {
+                goAdjustMusic(recordId, title, coverImg);
             }
 
             /**
@@ -302,30 +304,22 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
         startService(intentOne);
     }
 
-    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 goAdjustMusic(String recordId, String title, String coverImg) {
+        if (TextUtils.isEmpty(accompanimentUrl)) {
+            return;
+        }
+        String recordFilePath = MyFileUtils.getRecordFilePath();
+        if (!TextUtils.isEmpty(filePath)) {
+            recordFilePath = filePath;
+        }
+        ARouter.getInstance().build(RouterPath.MusicTuner.MUSIC_MERGE_PAGE)
+                .withString("accompanyUrl", accompanimentUrl)
+                .withString("recordFilePath", recordFilePath)
+                .withString("recordId", recordId)
+                .withString("title", title)
+                .withString("coverImg", coverImg)
+                .withInt("c_orientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
+                .navigation(this, SAVE_PRACTICE_REQUEST_CODE);
     }
 
     private void handleFileResult(String filePath) {
@@ -427,6 +421,16 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
                 }
                 return;
             }
+
+            if (requestCode == SAVE_PRACTICE_REQUEST_CODE) {
+                if (data != null) {
+                    int result = data.getIntExtra("saveWorksStatus", 0);
+                    if (result == 1) {
+                        sendSaveSuccessMsg();
+                    }
+                }
+                return;
+            }
         }
         if (requestCode == ADD_ACCOMPANIMENT_CODE) {
             try {
@@ -463,6 +467,18 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
         }
     }
 
+    private void sendSaveSuccessMsg() {
+        JSONObject json = new JSONObject();
+        try {
+            JSONObject content = new JSONObject();
+            json.put("api", "hideComplexButton");
+            json.put("content", content);
+            accompanyFragment.onSendMessage(json.toString());
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
     @Override
     protected void onStop() {
         if (cameraView != null) {

+ 150 - 129
teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyFragment.java

@@ -458,7 +458,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
     }
 
     private void showLoadingAnim() {
-        if (mViewBinding!=null && mViewBinding.llLoading.getVisibility() != View.VISIBLE) {
+        if (mViewBinding != null && mViewBinding.llLoading.getVisibility() != View.VISIBLE) {
             currentProgressCount = 0;
             mViewBinding.progress.setProgress(0);
             mViewBinding.ivLoadingBack.setVisibility(View.VISIBLE);
@@ -482,39 +482,39 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         msg = message;
         if (webSocketClient == null) {
             Observable.create(new ObservableOnSubscribe<String>() {
-                @Override
-                public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Exception {
-                    Map<String, String> httpHeaders = new HashMap<String, String>();
-                    httpHeaders.put("Authorization", UserHelper.getUserToken());
-                    webSocketClient = new JWebSocketClient(webSocketUri, httpHeaders) {
                         @Override
-                        public void onMessage(String message) {
-                            emitter.onNext(message);
-                        }
+                        public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Exception {
+                            Map<String, String> httpHeaders = new HashMap<String, String>();
+                            httpHeaders.put("Authorization", UserHelper.getUserToken());
+                            webSocketClient = new JWebSocketClient(webSocketUri, httpHeaders) {
+                                @Override
+                                public void onMessage(String message) {
+                                    emitter.onNext(message);
+                                }
 
-                        @Override
-                        public void onError(Exception ex) {
-                            super.onError(ex);
-                            emitter.onNext("-2");
-                        }
+                                @Override
+                                public void onError(Exception ex) {
+                                    super.onError(ex);
+                                    emitter.onNext("-2");
+                                }
 
-                        @Override
-                        public void onOpen(ServerHandshake handshakedata) {
-                            super.onOpen(handshakedata);
-                            emitter.onNext("-1");
+                                @Override
+                                public void onOpen(ServerHandshake handshakedata) {
+                                    super.onOpen(handshakedata);
+                                    emitter.onNext("-1");
 
-                        }
+                                }
 
-                        @Override
-                        public void onClose(int code, String reason, boolean remote) {
-                            super.onClose(code, reason, remote);
-                            emitter.onNext("-2");
+                                @Override
+                                public void onClose(int code, String reason, boolean remote) {
+                                    super.onClose(code, reason, remote);
+                                    emitter.onNext("-2");
+                                }
+                            };
+                            webSocketClient.setConnectionLostTimeout(60 * 1000);
+                            webSocketClient.connect();
                         }
-                    };
-                    webSocketClient.setConnectionLostTimeout(60 * 1000);
-                    webSocketClient.connect();
-                }
-            }).subscribeOn(Schedulers.newThread())
+                    }).subscribeOn(Schedulers.newThread())
                     .observeOn(AndroidSchedulers.mainThread())
                     .subscribe(new Observer<String>() {
                         @Override
@@ -692,29 +692,29 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
             wavRecorder.startRecording(getContext());
         } else {
             Observable.create((ObservableOnSubscribe<String>) emitter -> {
-                wavRecorder = MsRecorder.wav(
-                        new File(getVoicePath()),
-                        new AudioRecordConfig(),
-                        // AudioRecordConfig(MediaRecorder.AudioSource.MIC, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100),
-                        new PullTransport.Default().setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
-                            @Override
-                            public void onAudioChunkPulled(AudioChunk audioChunk) {
-                                if (webSocketClient != null && webSocketClient.isOpen()) {
-                                    webSocketClient.send(audioChunk.toBytes());
-                                    if (isSendRecordStartTime) {
-                                        isSendRecordStartTime = false;
-                                        emitter.onNext("-2");
+                        wavRecorder = MsRecorder.wav(
+                                new File(getVoicePath()),
+                                new AudioRecordConfig(),
+                                // AudioRecordConfig(MediaRecorder.AudioSource.MIC, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100),
+                                new PullTransport.Default().setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
+                                    @Override
+                                    public void onAudioChunkPulled(AudioChunk audioChunk) {
+                                        if (webSocketClient != null && webSocketClient.isOpen()) {
+                                            webSocketClient.send(audioChunk.toBytes());
+                                            if (isSendRecordStartTime) {
+                                                isSendRecordStartTime = false;
+                                                emitter.onNext("-2");
+                                            }
+                                        } else {
+                                            emitter.onNext("-1");
+                                        }
                                     }
-                                } else {
-                                    emitter.onNext("-1");
-                                }
-                            }
-                        }));
-                if (wavRecorder != null) {
-                    wavRecorder.startRecording(getContext());
-                }
-                emitter.onNext("1");
-            }).subscribeOn(Schedulers.newThread())
+                                }));
+                        if (wavRecorder != null) {
+                            wavRecorder.startRecording(getContext());
+                        }
+                        emitter.onNext("1");
+                    }).subscribeOn(Schedulers.newThread())
                     .observeOn(AndroidSchedulers.mainThread())
                     .subscribe(new Observer<String>() {
                         @Override
@@ -865,29 +865,29 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
             wavRecorder.startRecording(getContext());
         } else {
             Observable.create((ObservableOnSubscribe<String>) emitter -> {
-                wavRecorder = MsRecorder.wav(
-                        new File(getVoicePath()),
-                        new AudioRecordConfig(),
-                        // AudioRecordConfig(MediaRecorder.AudioSource.MIC, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100),
-                        new PullTransport.Default().setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
-                            @Override
-                            public void onAudioChunkPulled(AudioChunk audioChunk) {
-                                if (webSocketClient != null && webSocketClient.isOpen()) {
-                                    webSocketClient.send(audioChunk.toBytes());
-                                    if (isSoundCheckStartTime) {
-                                        isSoundCheckStartTime = false;
-                                        emitter.onNext("-2");
+                        wavRecorder = MsRecorder.wav(
+                                new File(getVoicePath()),
+                                new AudioRecordConfig(),
+                                // AudioRecordConfig(MediaRecorder.AudioSource.MIC, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100),
+                                new PullTransport.Default().setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
+                                    @Override
+                                    public void onAudioChunkPulled(AudioChunk audioChunk) {
+                                        if (webSocketClient != null && webSocketClient.isOpen()) {
+                                            webSocketClient.send(audioChunk.toBytes());
+                                            if (isSoundCheckStartTime) {
+                                                isSoundCheckStartTime = false;
+                                                emitter.onNext("-2");
+                                            }
+                                        } else {
+                                            emitter.onNext("-1");
+                                        }
                                     }
-                                } else {
-                                    emitter.onNext("-1");
-                                }
-                            }
-                        }));
-                if (wavRecorder != null) {
-                    wavRecorder.startRecording(getContext());
-                }
-                emitter.onNext("1");
-            }).subscribeOn(Schedulers.newThread())
+                                }));
+                        if (wavRecorder != null) {
+                            wavRecorder.startRecording(getContext());
+                        }
+                        emitter.onNext("1");
+                    }).subscribeOn(Schedulers.newThread())
                     .observeOn(AndroidSchedulers.mainThread())
                     .subscribe(new Observer<String>() {
                         @Override
@@ -972,7 +972,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
     // 录音文件存储名称
     private String getVoicePath() {
-        return MyFileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
+        return MyFileUtils.getRecordFilePath();
     }
 
     /**
@@ -1466,6 +1466,8 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
          * @param url
          */
         void onDownloadAccompaniment(String url);
+
+        void openAdjustRecording(String recordId, String title, String coverImg);
     }
 
     public WebViewListener listener;
@@ -1492,7 +1494,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
                 String videoUrl = content.getString("video");
                 /*增加自定义按钮的分享面板*/
                 mShareAction = new ShareAction(getActivity()).setDisplayList(
-                        SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
+                                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
                         .setShareboardclickCallback(new ShareBoardlistener() {
                             @Override
                             public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
@@ -1512,7 +1514,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
                 String shareUrl = WebParamsUtils.getShareUrl(content);
                 /*增加自定义按钮的分享面板*/
                 mShareAction = new ShareAction(getActivity()).setDisplayList(
-                        SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
+                                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
                         .setShareboardclickCallback(new ShareBoardlistener() {
                             @Override
                             public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
@@ -2060,6 +2062,25 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         }
     }
 
+    @Override
+    public void openAdjustRecording(JSONObject message) {
+        if (message != null) {
+            JSONObject contentJson = message.optJSONObject("content");
+            if (contentJson != null) {
+                int recordIdByInt = contentJson.optInt("recordId", -1);
+                String recordId = String.valueOf(recordIdByInt);
+                if (recordIdByInt == -1) {
+                    recordId = contentJson.optString("recordId");
+                }
+                String title = contentJson.optString("title");
+                String coverImg = contentJson.optString("coverImg");
+                if (onAccompanyListener != null) {
+                    onAccompanyListener.openAdjustRecording(recordId, title, coverImg);
+                }
+            }
+        }
+    }
+
     private void handleCloudFollow(String mode) {
         if (mMusicTunerHelper == null) {
             mMusicTunerHelper = new MusicTunerHelper(new MusicTunerHelper.OnEventListener() {
@@ -2271,61 +2292,61 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         //弹出预备拍
         preCountDialog = CommonDialog.init().setLayoutId(com.cooleshow.base.R.layout.dialog_student_precount);
         preCountDialog.setConvertListener(new ViewConvertListener() {
-            @Override
-            public void convertView(ViewHolder holder, BaseDialog dialog) {
-                if (count == 2) {
-                    iv1 = holder.getView(com.cooleshow.base.R.id.iv_3);
-                    iv2 = holder.getView(com.cooleshow.base.R.id.iv_4);
-                    iv3 = holder.getView(com.cooleshow.base.R.id.iv_1);
-                    iv4 = holder.getView(com.cooleshow.base.R.id.iv_2);
-                    iv5 = holder.getView(com.cooleshow.base.R.id.iv_5);
-                    iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
-                    iv3.setVisibility(View.INVISIBLE);
-                    iv4.setVisibility(View.INVISIBLE);
-                    iv5.setVisibility(View.INVISIBLE);
-                    iv6.setVisibility(View.INVISIBLE);
-                } else if (count == 3) {
-                    iv1 = holder.getView(com.cooleshow.base.R.id.iv_3);
-                    iv2 = holder.getView(com.cooleshow.base.R.id.iv_4);
-                    iv3 = holder.getView(com.cooleshow.base.R.id.iv_5);
-                    iv4 = holder.getView(com.cooleshow.base.R.id.iv_2);
-                    iv5 = holder.getView(com.cooleshow.base.R.id.iv_1);
-                    iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
-                    iv4.setVisibility(View.INVISIBLE);
-                    iv5.setVisibility(View.INVISIBLE);
-                    iv6.setVisibility(View.INVISIBLE);
-                } else if (count == 4) {
-                    iv1 = holder.getView(com.cooleshow.base.R.id.iv_2);
-                    iv2 = holder.getView(com.cooleshow.base.R.id.iv_3);
-                    iv3 = holder.getView(com.cooleshow.base.R.id.iv_4);
-                    iv4 = holder.getView(com.cooleshow.base.R.id.iv_5);
-                    iv5 = holder.getView(com.cooleshow.base.R.id.iv_1);
-                    iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
-                    iv5.setVisibility(View.INVISIBLE);
-                    iv6.setVisibility(View.INVISIBLE);
-                }
-                iv1.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
-                iv2.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
-                iv3.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
-                iv4.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
-                iv5.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
-                iv6.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
-                ImageView iv_dialog_student_precount = holder.getView(com.cooleshow.base.R.id.iv_dialog_student_precount);
-                iv_dialog_student_precount.setOnClickListener(v -> {
-                    dialog.dismiss();
-                    if (soundpool != null) {
-                        soundpool.release();
-                        soundpool = null;
-                    }
-                    try {
-                        message.optJSONObject("content").put("status", "cancel");
-                    } catch (JSONException e) {
-                        e.printStackTrace();
+                    @Override
+                    public void convertView(ViewHolder holder, BaseDialog dialog) {
+                        if (count == 2) {
+                            iv1 = holder.getView(com.cooleshow.base.R.id.iv_3);
+                            iv2 = holder.getView(com.cooleshow.base.R.id.iv_4);
+                            iv3 = holder.getView(com.cooleshow.base.R.id.iv_1);
+                            iv4 = holder.getView(com.cooleshow.base.R.id.iv_2);
+                            iv5 = holder.getView(com.cooleshow.base.R.id.iv_5);
+                            iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
+                            iv3.setVisibility(View.INVISIBLE);
+                            iv4.setVisibility(View.INVISIBLE);
+                            iv5.setVisibility(View.INVISIBLE);
+                            iv6.setVisibility(View.INVISIBLE);
+                        } else if (count == 3) {
+                            iv1 = holder.getView(com.cooleshow.base.R.id.iv_3);
+                            iv2 = holder.getView(com.cooleshow.base.R.id.iv_4);
+                            iv3 = holder.getView(com.cooleshow.base.R.id.iv_5);
+                            iv4 = holder.getView(com.cooleshow.base.R.id.iv_2);
+                            iv5 = holder.getView(com.cooleshow.base.R.id.iv_1);
+                            iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
+                            iv4.setVisibility(View.INVISIBLE);
+                            iv5.setVisibility(View.INVISIBLE);
+                            iv6.setVisibility(View.INVISIBLE);
+                        } else if (count == 4) {
+                            iv1 = holder.getView(com.cooleshow.base.R.id.iv_2);
+                            iv2 = holder.getView(com.cooleshow.base.R.id.iv_3);
+                            iv3 = holder.getView(com.cooleshow.base.R.id.iv_4);
+                            iv4 = holder.getView(com.cooleshow.base.R.id.iv_5);
+                            iv5 = holder.getView(com.cooleshow.base.R.id.iv_1);
+                            iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
+                            iv5.setVisibility(View.INVISIBLE);
+                            iv6.setVisibility(View.INVISIBLE);
+                        }
+                        iv1.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv2.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv3.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv4.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv5.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv6.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        ImageView iv_dialog_student_precount = holder.getView(com.cooleshow.base.R.id.iv_dialog_student_precount);
+                        iv_dialog_student_precount.setOnClickListener(v -> {
+                            dialog.dismiss();
+                            if (soundpool != null) {
+                                soundpool.release();
+                                soundpool = null;
+                            }
+                            try {
+                                message.optJSONObject("content").put("status", "cancel");
+                            } catch (JSONException e) {
+                                e.printStackTrace();
+                            }
+                            onSendMessage(message.toString());
+                        });
                     }
-                    onSendMessage(message.toString());
-                });
-            }
-        })
+                })
                 .setDimAmount(0.6f)
                 .setOutCancel(true)
                 .setGravity(Gravity.CENTER)

+ 9 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceAccomPanyUtils.java

@@ -361,6 +361,13 @@ public class JsInterfaceAccomPanyUtils extends Object {
                     }
                     return;
                 }
+
+                if (TextUtils.equals(WebApi.API_OPEN_ADJUST_RECORDING, api)) {
+                    if (onListener != null) {
+                        onListener.openAdjustRecording(jsonObject);
+                    }
+                    return;
+                }
             } catch (Exception e) {
 
             }
@@ -647,6 +654,8 @@ public class JsInterfaceAccomPanyUtils extends Object {
          * @param url
          */
         void saveAccompanimentMp3(String url);
+
+        void openAdjustRecording(JSONObject message);
     }
 
 }