From 3c696793619750511f660d2b0ff8b303cb9fd081 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 27 十月 2020 15:21:54 +0800
Subject: [PATCH] 2020-10-27 1.修改音乐协议

---
 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java |   67 ++++++++++++++++++++-------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java
index 19c9d39..aff1911 100644
--- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java
+++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java
@@ -193,7 +193,8 @@
             EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_VOLUME, 79 - (Integer.parseInt(volNum)), audioInfo));
         } else if (isExitData(arrMusicData[0], "TYPE")) {
             Log.i("djl","Type ----> musicData = "+musicData);
-            byte[] musicBytes = audioGetListParse(curListNum, 1);
+            String sourceId = musicData.substring(4, 5);
+            byte[] musicBytes = audioGetListParse(curListNum, 1, sourceId);
             sendAudioData(getDatas, musicBytes);
         } else if (isExitData(arrMusicData[0], "LIST")) {
 
@@ -203,7 +204,8 @@
             }
             int intNum = Integer.parseInt(num);
             if (curListNum == intNum) {//鍒ゆ柇鍥炲鐨勬暟鎹槸鍚︿负褰撳墠鍒楄〃鏁�
-                byte[] musicBytes = audioGetListParse(curListNum, 2);
+                String sourceId = musicData.substring(4, 5);
+                byte[] musicBytes = audioGetListParse(curListNum, 2, sourceId);
                 sendAudioData(getDatas, musicBytes);
             }
         } else if (isExitData(arrMusicData[0], "SONG")) {
@@ -306,15 +308,18 @@
                 strAsc += intAsc / 10;
                 strAsc += intAsc % 10;
             }
-            String byteAsc = stringToAscii(strAsc);
-            String[] arrAsc = byteAsc.split(",");
-            int a1 = Integer.parseInt(arrAsc[0]);
-            int a2 = Integer.parseInt(arrAsc[1]);
-            return new byte[]{0x2A, 0x5A, 0x31, 0x56, 0x4F, 0x4C, (byte) a1, (byte) a2, 0x0D};
+//            String byteAsc = stringToAscii(strAsc);
+//            String[] arrAsc = byteAsc.split(",");
+//            int a1 = Integer.parseInt(arrAsc[0]);
+//            int a2 = Integer.parseInt(arrAsc[1]);
+//            return new byte[]{0x2A, 0x5A, 0x31, 0x56, 0x4F, 0x4C, (byte) a1, (byte) a2, 0x0D};
+
+            byte[] musicBytes =  StringUtil.GetMusicBytes("*Z1VOL" + strAsc);
+            return musicBytes;
         }
     }
 
-    public static byte[] audioChooseSongParse(int value1, int value2) {
+    public static byte[] audioChooseSongParse(int value1, int value2, int sourceId) {
         int listNum = value1;
         int songNum = value2 + 1;
         String songNumStrAsc = "";
@@ -335,25 +340,28 @@
             listNumStrAsc += listNum;
         }
 
-        String songNumByteAsc = stringToAscii(songNumStrAsc);
-        String listNumByteAsc = stringToAscii(listNumStrAsc);
-
-        String[] songNumArrAsc = songNumByteAsc.split(",");
-        String[] listNumArrAsc = listNumByteAsc.split(",");
-
-        int a1 = Integer.parseInt(songNumArrAsc[0]);
-        int a2 = Integer.parseInt(songNumArrAsc[1]);
-        int a3 = Integer.parseInt(songNumArrAsc[2]);
-
-        int b1 = Integer.parseInt(listNumArrAsc[0]);
-        int b2 = Integer.parseInt(listNumArrAsc[1]);
-        int b3 = Integer.parseInt(listNumArrAsc[2]);
+//        String songNumByteAsc = stringToAscii(songNumStrAsc);
+//        String listNumByteAsc = stringToAscii(listNumStrAsc);
+//
+//        String[] songNumArrAsc = songNumByteAsc.split(",");
+//        String[] listNumArrAsc = listNumByteAsc.split(",");
+//
+//        int a1 = Integer.parseInt(songNumArrAsc[0]);
+//        int a2 = Integer.parseInt(songNumArrAsc[1]);
+//        int a3 = Integer.parseInt(songNumArrAsc[2]);
+//
+//        int b1 = Integer.parseInt(listNumArrAsc[0]);
+//        int b2 = Integer.parseInt(listNumArrAsc[1]);
+//        int b3 = Integer.parseInt(listNumArrAsc[2]);
 //*Z011SONG001
-            return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x53, 0x4F, 0x4E, 0x47, 0x30
-                , 0x30, 0x31, (byte) b1, (byte) b2, (byte) b3, (byte) a1, (byte) a2, (byte) a3, 0x32, 0x0D};
+//            return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x53, 0x4F, 0x4E, 0x47, 0x30
+//                , 0x30, 0x31, (byte) b1, (byte) b2, (byte) b3, (byte) a1, (byte) a2, (byte) a3, 0x32, 0x0D};
+
+        byte[] musicBytes =  StringUtil.GetMusicBytes("*Z01" + sourceId+ "SONG" +listNumStrAsc + songNumStrAsc + "2");
+        return musicBytes;
     }
 
-    private static byte[] audioGetListParse(int num, int type) {
+    private static byte[] audioGetListParse(int num, int type, String sourceId) {
         String strAsc = "";
         if (num < 10) {
             strAsc = "00" + num;
@@ -368,10 +376,15 @@
         int a2 = Integer.parseInt(arrAsc[1]);
         int a3 = Integer.parseInt(arrAsc[2]);
         if (type == 1) {
-            return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x4C, 0x49, 0x53,
-                    0x54, 0x30, 0x30, 0x31, (byte) a1, (byte) a2, (byte) a3, 0x31, 0x0D};
+//            return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x4C, 0x49, 0x53,
+//                    0x54, 0x30, 0x30, 0x31, (byte) a1, (byte) a2, (byte) a3, 0x31, 0x0D};
+            byte[] musicBytes =  StringUtil.GetMusicBytes("*Z01" + sourceId + "LIST001" + strAsc + "1");
+            return musicBytes;
+
         } else {
-            return new byte[]{42, 90, 48, 49, 49, 83, 79, 78, 71, 48, 48, 49, (byte) a1, (byte) a2, (byte) a3, 48, 48, 49, 49, 13};
+//            return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x53, 0x4F, 0x4E, 0x47, 0x30, 0x30, 0x31, (byte) a1, (byte) a2, (byte) a3, 0x30, 0x30, 0x31, 0x31, 0x0D};
+            byte[] musicBytes =  StringUtil.GetMusicBytes("*Z01" + sourceId + "SONG001" + strAsc + "0011");
+            return musicBytes;
         }
     }
 }

--
Gitblit v1.8.0