mirror of
https://gitea.winboll.cc/ZhanGSKen/MyWinBoLL.git
synced 2026-08-14 13:37:11 +08:00
fix: 将 TTS 延迟方式从 Thread.sleep 改为 Handler.postDelayed
确保悬浮窗先完成渲染,再延时播放语音,避免 Thread.sleep 阻塞主线程导致窗口无法显示。
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Jun 24 09:28:12 CST 2026
|
#Wed Jun 24 09:36:16 CST 2026
|
||||||
stageCount=12
|
stageCount=12
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.12
|
baseVersion=15.12
|
||||||
publishVersion=15.12.11
|
publishVersion=15.12.11
|
||||||
buildCount=4
|
buildCount=5
|
||||||
baseBetaVersion=15.12.12
|
baseBetaVersion=15.12.12
|
||||||
|
|||||||
+14
-15
@@ -65,24 +65,23 @@ public class TextToSpeechUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initWindow(); // 已同步尺寸和位置
|
initWindow(); // 先弹出悬浮窗口
|
||||||
|
|
||||||
int nDelay = listTTSSpeakTextBean.get(0).mnDelay;
|
int nDelay = listTTSSpeakTextBean.get(0).mnDelay;
|
||||||
try {
|
new android.os.Handler(mContext.getMainLooper()).postDelayed(new Runnable() {
|
||||||
Thread.sleep(nDelay);
|
@Override
|
||||||
} catch (InterruptedException e) {
|
public void run() {
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
for (int speakPosition = 0; speakPosition < listTTSSpeakTextBean.size() && !isExist; speakPosition++) {
|
||||||
}
|
String szSpeakContent = listTTSSpeakTextBean.get(speakPosition).mszSpeakContent;
|
||||||
|
isExist = (listTTSSpeakTextBean.size() - 2 < speakPosition);
|
||||||
for (int speakPosition = 0; speakPosition < listTTSSpeakTextBean.size() && !isExist; speakPosition++) {
|
if (speakPosition == 0) {
|
||||||
String szSpeakContent = listTTSSpeakTextBean.get(speakPosition).mszSpeakContent;
|
mTextToSpeech.speak(szSpeakContent, TextToSpeech.QUEUE_FLUSH, null, UNIQUE_ID);
|
||||||
isExist = (listTTSSpeakTextBean.size() - 2 < speakPosition);
|
} else {
|
||||||
if (speakPosition == 0) {
|
mTextToSpeech.speak(szSpeakContent, TextToSpeech.QUEUE_ADD, null, UNIQUE_ID);
|
||||||
mTextToSpeech.speak(szSpeakContent, TextToSpeech.QUEUE_FLUSH, null, UNIQUE_ID);
|
}
|
||||||
} else {
|
}
|
||||||
mTextToSpeech.speak(szSpeakContent, TextToSpeech.QUEUE_ADD, null, UNIQUE_ID);
|
|
||||||
}
|
}
|
||||||
}
|
}, nDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user