|
@@ -1559,7 +1559,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
if (Math.abs(midiFileDuration - tempDuration * 1000) > 2000) {
|
|
if (Math.abs(midiFileDuration - tempDuration * 1000) > 2000) {
|
|
midiFileDuration = (long) (tempDuration * 1000);
|
|
midiFileDuration = (long) (tempDuration * 1000);
|
|
}
|
|
}
|
|
- JSONObject contentJsonObject =message.optJSONObject("content");
|
|
|
|
|
|
+ JSONObject contentJsonObject = message.optJSONObject("content");
|
|
if (contentJsonObject != null) {
|
|
if (contentJsonObject != null) {
|
|
contentJsonObject.put("midiDuration", midiFileDuration);
|
|
contentJsonObject.put("midiDuration", midiFileDuration);
|
|
contentJsonObject.put("midi", EncodeUtils.urlEncode(midiFile));
|
|
contentJsonObject.put("midi", EncodeUtils.urlEncode(midiFile));
|
|
@@ -1587,7 +1587,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
midiFileDuration = (long) (tempDuration * 1000);
|
|
midiFileDuration = (long) (tempDuration * 1000);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- JSONObject contentJsonObject =message.optJSONObject("content");
|
|
|
|
|
|
+ JSONObject contentJsonObject = message.optJSONObject("content");
|
|
if (contentJsonObject != null) {
|
|
if (contentJsonObject != null) {
|
|
contentJsonObject.put("midiDuration", midiFileDuration);
|
|
contentJsonObject.put("midiDuration", midiFileDuration);
|
|
contentJsonObject.put("midi", EncodeUtils.urlEncode(midiFile));
|
|
contentJsonObject.put("midi", EncodeUtils.urlEncode(midiFile));
|
|
@@ -1774,13 +1774,17 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void cloudVolume(JSONObject message) {
|
|
public void cloudVolume(JSONObject message) {
|
|
-
|
|
|
|
try {
|
|
try {
|
|
JSONObject obj = message.optJSONObject("content");
|
|
JSONObject obj = message.optJSONObject("content");
|
|
- JSONArray array = obj.optJSONArray("parts");
|
|
|
|
- for (int i = 0; i < array.length(); i++) {
|
|
|
|
- MidiPlayerUtils.getInstance().setTrackVolumeByName(array.optJSONObject(i).optString("name"), (float) array.optJSONObject(i).optInt("volume", 70) / 100f);
|
|
|
|
|
|
+ if (obj != null) {
|
|
|
|
+ int activeMidiId = obj.optInt("activeMidiId");
|
|
|
|
+ int activeMidiVolume = obj.optInt("activeMidiVolume", 70);
|
|
|
|
+ if (activeMidiId == -1) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ MidiPlayerUtils.getInstance().setTrackVolumeById(activeMidiId, (float) activeMidiVolume / 100f);
|
|
}
|
|
}
|
|
|
|
+ sendMessage(message.toString());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
sendMessage(message.toString());
|
|
sendMessage(message.toString());
|