Browse Source

优化qq音乐相关bug代码

newdev_shunjiawei
liwei1dao 1 year ago
parent
commit
59b38a6dc6
  1. 4
      local_plugins/azure_speech/ios/azure_speech/Sources/tools/SimpleAudioReceiver.swift
  2. 5
      local_plugins/qq_music/android/src/main/kotlin/com/yunqiinnovation/qq_music/QQMusicSingleton.kt
  3. 17
      local_plugins/qq_music/ios/qq_music/Sources/qq_music/QPlayAutoManager.swift
  4. 2
      pubspec.yaml

4
local_plugins/azure_speech/ios/azure_speech/Sources/tools/SimpleAudioReceiver.swift

@ -151,10 +151,10 @@ public class SimpleAudioReceiver: NSObject {
}
try self.pushAudioStream?.write(dataToWrite)
if self.recordfile != nil {
print("写入recordfile数据长度: \(dataToWrite.count)")
// print("写入recordfile数据长度: \(dataToWrite.count)")
recordfile?.saveAudioDataToWav(dataToWrite)
}
print("写入数据长度: \(dataToWrite.count)")
// print("写入数据长度: \(dataToWrite.count)")
} catch {
print("推送音频数据失败: \(error.localizedDescription)")
}

5
local_plugins/qq_music/android/src/main/kotlin/com/yunqiinnovation/qq_music/QQMusicSingleton.kt

@ -286,7 +286,7 @@ class QQMusicSingleton private constructor() {
completed = true
searchTimeouts.remove(searchKey)?.let { handler.removeCallbacks(it) }
Log.e(TAG, "搜索失败: code=$errorCode, message=$errorMessage")
// 如果是登录相关错误,清除本地登录信息
if (errorMessage.contains("登录") || errorMessage.contains("授权")) {
Log.d(TAG, "检测到登录相关错误,清除本地登录信息")
@ -298,6 +298,9 @@ class QQMusicSingleton private constructor() {
(errorMessage.contains("网络") || errorMessage.contains("超时") ||
errorMessage.contains("连接") || errorCode == -1)) {
Log.d(TAG, "网络错误,准备重试: ${retryCount + 1}/$MAX_RETRY_COUNT")
if (errorCode == -1){
musicManager?.bindQQMusicApiService()
}
handler.postDelayed({
searchWithRetry(keyword, searchType, retryCount + 1, callback)
}, RETRY_DELAY_MS)

17
local_plugins/qq_music/ios/qq_music/Sources/qq_music/QPlayAutoManager.swift

@ -251,9 +251,10 @@ import QPlayAutoSDK
let startTime = Date()
print("QPlayAutoManager: 调用 QPlayAutoSDK.connectAndForceLogin(\(forceLogin))")
QPlayAutoSDK.connectAndForceLogin(forceLogin)
// 增加超时时间,特别是强制登录时
let timeoutInterval: TimeInterval = forceLogin ? 45.0 : 10.0
// If connection fails due to socket error, retry after cleanup
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
DispatchQueue.main.asyncAfter(deadline: .now() + timeoutInterval) {
let endTime = Date()
let duration = endTime.timeIntervalSince(startTime)
@ -410,7 +411,7 @@ import QPlayAutoSDK
connect(forceLogin: true)
// 设置超时监控(仅记录,不清理回调)
DispatchQueue.main.asyncAfter(deadline: .now() + 30.0) { [weak self] in
DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) { [weak self] in
self?.logLoginTimeout()
}
}
@ -827,6 +828,16 @@ extension QPlayAutoManager: QPlayAutoSDKDelegate {
print("QPlayAutoManager: ❌ 登录失败,但不立即清理回调(等待重试或最终失败)")
// 注意:这里不立即调用 notifyLoginCompletion(false)
// 让重试机制来决定是否最终失败
// 如果有等待的回调且不在重试过程中,则通知失败
if !loginCompletionHandlers.isEmpty {
// 给一个短暂的延迟,让重试机制有机会处理
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
if !self.loginCompletionHandlers.isEmpty && !self.isLoginOK {
print("QPlayAutoManager: 登录失败,清理回调队列")
self.notifyLoginCompletion(false)
}
}
}
}
// 通知所有代理

2
pubspec.yaml

@ -1,7 +1,7 @@
name: voitrans
description: "Voitrans - AI Voice Assistant."
publish_to: "none"
version: 1.0.7+20
version: 1.0.9+20
environment:
sdk: ">=3.3.0 <4.0.0"

Loading…
Cancel
Save