|  | @@ -416,7 +416,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                          } catch (JSONException e) {
 |  |                          } catch (JSONException e) {
 | 
											
												
													
														|  |                              e.printStackTrace();
 |  |                              e.printStackTrace();
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  | -                        UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启麦克风访问权限");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                        UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启麦克风访问权限");
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  |                  });
 |  |                  });
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -444,7 +444,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      private void showLoadingAnim() {
 |  |      private void showLoadingAnim() {
 | 
											
												
													
														|  | -        if (mViewBinding!=null && mViewBinding.llLoading.getVisibility() != View.VISIBLE) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (mViewBinding != null && mViewBinding.llLoading.getVisibility() != View.VISIBLE) {
 | 
											
												
													
														|  |              currentProgressCount = 0;
 |  |              currentProgressCount = 0;
 | 
											
												
													
														|  |              mViewBinding.progress.setProgress(0);
 |  |              mViewBinding.progress.setProgress(0);
 | 
											
												
													
														|  |              mViewBinding.ivLoadingBack.setVisibility(View.VISIBLE);
 |  |              mViewBinding.ivLoadingBack.setVisibility(View.VISIBLE);
 | 
											
										
											
												
													
														|  | @@ -461,7 +461,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      private void hideLoadingAnim() {
 |  |      private void hideLoadingAnim() {
 | 
											
												
													
														|  | -        if(mViewBinding!=null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (mViewBinding != null) {
 | 
											
												
													
														|  |              currentProgressCount = 0;
 |  |              currentProgressCount = 0;
 | 
											
												
													
														|  |              mViewBinding.ivLoadingBack.setVisibility(View.GONE);
 |  |              mViewBinding.ivLoadingBack.setVisibility(View.GONE);
 | 
											
												
													
														|  |              mViewBinding.viewLoadingAnim.cancelAnimation();
 |  |              mViewBinding.viewLoadingAnim.cancelAnimation();
 | 
											
										
											
												
													
														|  | @@ -736,7 +736,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                                  long bufferDuration = (long) wavRecorder.getBufferDuration();
 |  |                                  long bufferDuration = (long) wavRecorder.getBufferDuration();
 | 
											
												
													
														|  |                                  long time = System.currentTimeMillis();
 |  |                                  long time = System.currentTimeMillis();
 | 
											
												
													
														|  |                                  long result = time - bufferDuration;
 |  |                                  long result = time - bufferDuration;
 | 
											
												
													
														|  | -                                mPlayHelper.toPlay2(result,getFirstNoteTime(message),isMuteMode(message));
 |  | 
 | 
											
												
													
														|  | 
 |  | +                                mPlayHelper.toPlay2(result, getFirstNoteTime(message), isMuteMode(message));
 | 
											
												
													
														|  |                              } else if ("1".equals(recorder)) {
 |  |                              } else if ("1".equals(recorder)) {
 | 
											
												
													
														|  |  //                                onSendMessage(message.toString());
 |  |  //                                onSendMessage(message.toString());
 | 
											
												
													
														|  |                              } else {
 |  |                              } else {
 | 
											
										
											
												
													
														|  | @@ -783,7 +783,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private int getFirstNoteTime(JSONObject jsonObject){
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private int getFirstNoteTime(JSONObject jsonObject) {
 | 
											
												
													
														|  |          if (jsonObject == null) {
 |  |          if (jsonObject == null) {
 | 
											
												
													
														|  |              return 0;
 |  |              return 0;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
										
											
												
													
														|  | @@ -835,7 +835,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                          if (permission) {
 |  |                          if (permission) {
 | 
											
												
													
														|  |                              startWebSocketClient(message);
 |  |                              startWebSocketClient(message);
 | 
											
												
													
														|  |                          } else {
 |  |                          } else {
 | 
											
												
													
														|  | -                            UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启麦克风访问权限");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                            UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启麦克风访问权限");
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  |                      });
 |  |                      });
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
										
											
												
													
														|  | @@ -1074,12 +1074,11 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |      @SuppressLint("CheckResult")
 |  |      @SuppressLint("CheckResult")
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public void isWiredHeadsetOn(JSONObject jsonObject) {
 |  |      public void isWiredHeadsetOn(JSONObject jsonObject) {
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              JSONObject content = jsonObject.getJSONObject("content");
 |  |              JSONObject content = jsonObject.getJSONObject("content");
 | 
											
												
													
														|  | -            content.put("checkIsWired", !TextUtils.isEmpty(checkType()));
 |  | 
 | 
											
												
													
														|  | -            content.put("type", checkType());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            String s = com.daya.orchestra.accompany.utils.Utils.checkType(getContext());
 | 
											
												
													
														|  | 
 |  | +            content.put("checkIsWired", !TextUtils.isEmpty(s));
 | 
											
												
													
														|  | 
 |  | +            content.put("type", s);
 | 
											
												
													
														|  |              onSendMessage(jsonObject.toString());
 |  |              onSendMessage(jsonObject.toString());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |              if (webSocketClient != null) {
 |  |              if (webSocketClient != null) {
 | 
											
										
											
												
													
														|  | @@ -1181,7 +1180,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                          } catch (JSONException e) {
 |  |                          } catch (JSONException e) {
 | 
											
												
													
														|  |                              e.printStackTrace();
 |  |                              e.printStackTrace();
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  | -                        UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启摄像头、麦克风、储存访问权限");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                        UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启摄像头、麦克风、储存访问权限");
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  |                  });
 |  |                  });
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1214,7 +1213,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                          } catch (JSONException e) {
 |  |                          } catch (JSONException e) {
 | 
											
												
													
														|  |                              e.printStackTrace();
 |  |                              e.printStackTrace();
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  | -                        UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启摄像头、麦克风、储存访问权限");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                        UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启摄像头、麦克风、储存访问权限");
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  |                  });
 |  |                  });
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1232,38 +1231,6 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |          }, 1500);
 |  |          }, 1500);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private String checkType() {
 |  | 
 | 
											
												
													
														|  | -        AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
 |  | 
 | 
											
												
													
														|  | -        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
 |  | 
 | 
											
												
													
														|  | -            AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
 |  | 
 | 
											
												
													
														|  | -            for (AudioDeviceInfo device : devices) {
 |  | 
 | 
											
												
													
														|  | -                int deviceType = device.getType();
 |  | 
 | 
											
												
													
														|  | -                if (deviceType == AudioDeviceInfo.TYPE_WIRED_HEADSET || deviceType == AudioDeviceInfo.TYPE_WIRED_HEADPHONES) {
 |  | 
 | 
											
												
													
														|  | -                    return "有线耳机";
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                if (deviceType == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
 |  | 
 | 
											
												
													
														|  | -                        || deviceType == AudioDeviceInfo.TYPE_BLUETOOTH_SCO) {
 |  | 
 | 
											
												
													
														|  | -                    return "蓝牙耳机";
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                if (deviceType == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
 |  | 
 | 
											
												
													
														|  | -                    if (Constants.HEADSET_PLUE_TAG.isEmpty()) {
 |  | 
 | 
											
												
													
														|  | -                        return null;
 |  | 
 | 
											
												
													
														|  | -                    } else {
 |  | 
 | 
											
												
													
														|  | -                        return "有线耳机";
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -        } else {
 |  | 
 | 
											
												
													
														|  | -            if (audioManager.isWiredHeadsetOn()) {
 |  | 
 | 
											
												
													
														|  | -                return "有线耳机";
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            if (audioManager.isBluetoothScoOn() || audioManager.isBluetoothA2dpOn()) {
 |  | 
 | 
											
												
													
														|  | -                return "蓝牙耳机";
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        return null;
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public void videoUpdate(JSONObject jsonObject) {
 |  |      public void videoUpdate(JSONObject jsonObject) {
 | 
											
												
													
														|  |          if (onAccompanyListener != null)
 |  |          if (onAccompanyListener != null)
 | 
											
										
											
												
													
														|  | @@ -1768,7 +1735,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                                  e.printStackTrace();
 |  |                                  e.printStackTrace();
 | 
											
												
													
														|  |                              }
 |  |                              }
 | 
											
												
													
														|  |                          } else {
 |  |                          } else {
 | 
											
												
													
														|  | -                            UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启储存访问权限");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                            UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启储存访问权限");
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  |                      });
 |  |                      });
 | 
											
												
													
														|  |          } catch (Exception e) {
 |  |          } catch (Exception e) {
 | 
											
										
											
												
													
														|  | @@ -2068,18 +2035,18 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
											
												
													
														|  |                              mPlayHelper.startTune(message);
 |  |                              mPlayHelper.startTune(message);
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  |                      } else {
 |  |                      } else {
 | 
											
												
													
														|  | -                        sendNoPermissionMsg(message,"没有麦克风权限");
 |  | 
 | 
											
												
													
														|  | -                        UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启麦克风访问权限");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                        sendNoPermissionMsg(message, "没有麦克风权限");
 | 
											
												
													
														|  | 
 |  | +                        UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启麦克风访问权限");
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  |                  });
 |  |                  });
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private void sendNoPermissionMsg(JSONObject message,String tip){
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private void sendNoPermissionMsg(JSONObject message, String tip) {
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              JSONObject content = message.getJSONObject("content");
 |  |              JSONObject content = message.getJSONObject("content");
 | 
											
												
													
														|  |              content.put("reson", tip);
 |  |              content.put("reson", tip);
 | 
											
												
													
														|  |              onSendMessage(message.toString());
 |  |              onSendMessage(message.toString());
 | 
											
												
													
														|  | -        }catch (Exception e){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        } catch (Exception e) {
 | 
											
												
													
														|  |              e.printStackTrace();
 |  |              e.printStackTrace();
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 |