修改a2dp状态改变使用
authorhcj <1224667075@qq.com>
Tue, 6 Jan 2026 11:08:19 +0000 (19:08 +0800)
committerhcj <1224667075@qq.com>
Tue, 6 Jan 2026 11:08:19 +0000 (19:08 +0800)
code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c

index 3f6b253..1039367 100644 (file)
@@ -1092,10 +1092,15 @@ static void ai_binary_message_handler(const uint8_t *raw_data, uint32_t timestam
             if (g_ws_message_callback != NULL) {
                 g_ws_message_callback(NULL, WS_CMD_AUDIO_PLAYBACK_START);
             }
-            int ret = a2dp_src_start_playing(ln_bt_get_last_conned_device_Addr());  // 设置耳机的状态为播放
+            extern bool a2dp_is_connect;
+            if(a2dp_is_connect)
+            {
+                int ret = a2dp_src_start_playing(ln_bt_get_last_conned_device_Addr());  // 设置耳机的状态为播放
 
-            LN_WS_DEBUG("a2dp_src_start_playing %d \n", ret);
+                LN_WS_DEBUG("a2dp_src_start_playing %d \n", ret);
     
+            }
+ 
         }
         g_audio_playback_active = true;
 
@@ -3638,10 +3643,13 @@ static bool check_playback_completion_by_timeout(void)
         if (g_ws_message_callback != NULL) {
             g_ws_message_callback(NULL, WS_CMD_AUDIO_PLAYBACK_END);
         }
+        extern bool a2dp_is_connect;
+        if(a2dp_is_connect)
+        {
+            int ret = a2dp_src_suspend_playing(ln_bt_get_last_conned_device_Addr());  // 设置耳机的状态为播放
 
-        int ret = a2dp_src_suspend_playing(ln_bt_get_last_conned_device_Addr());  // 设置耳机的状态为播放
-
-        LN_WS_DEBUG("a2dp_src_suspend_playing %d \n", ret);
+            LN_WS_DEBUG("a2dp_src_suspend_playing %d \n", ret);
+        }
         
         return true; // 播放已完成
     }