feat: 优化播放延迟问题,并新增配置下一首播放的延迟秒数

This commit is contained in:
涵曦 2024-07-28 00:51:20 +00:00
parent 6b38676766
commit eab4f4bd46
7 changed files with 17 additions and 14 deletions

View File

@ -136,6 +136,7 @@ class Config:
remove_id3tag: bool = (
os.getenv("XIAOMUSIC_REMOVE_ID3TAG", "false").lower() == "true"
)
delay_sec: int = int(os.getenv("XIAOMUSIC_DELAY_SEC", 3)) # 下一首歌延迟播放秒数
def append_keyword(self, keys, action):
for key in keys.split(","):

View File

@ -5,9 +5,9 @@
<meta name="viewport" content="width=device-width">
<title>Debug For XiaoMusic</title>
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1721862430">
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1722127035">
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script src="/static/jquery-3.7.1.min.js?version=1721862430"></script>
<script src="/static/jquery-3.7.1.min.js?version=1722127035"></script>
<script>
var vConsole = new window.VConsole();

View File

@ -3,9 +3,9 @@
<head>
<meta name="viewport" content="width=device-width">
<title>小爱音箱操控面板</title>
<script src="/static/jquery-3.7.1.min.js?version=1721862430"></script>
<script src="/static/app.js?version=1721862430"></script>
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1721862430">
<script src="/static/jquery-3.7.1.min.js?version=1722127035"></script>
<script src="/static/app.js?version=1722127035"></script>
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1722127035">
<!--
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>M3U to JSON Converter</title>
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1721862430">
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1722127035">
<!--
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script>

View File

@ -3,9 +3,9 @@
<head>
<meta name="viewport" content="width=device-width">
<title>小爱音箱操控面板</title>
<script src="/static/jquery-3.7.1.min.js?version=1721862430"></script>
<script src="/static/setting.js?version=1721862430"></script>
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1721862430">
<script src="/static/jquery-3.7.1.min.js?version=1722127035"></script>
<script src="/static/setting.js?version=1722127035"></script>
<link rel="stylesheet" type="text/css" href="/static/style.css?version=1722127035">
<!--
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
@ -130,6 +130,9 @@ var vConsole = new window.VConsole();
<label for="public_port">外网访问端口(0表示跟监听端口一致):</label>
<input id="public_port" type="number" value="0"></input>
<label for="delay_sec">下一首歌延迟播放秒数:</label>
<input id="delay_sec" type="number" value="3"></input>
<label for="stop_tts_msg">停止提示音:</label>
<input id="stop_tts_msg" type="text" value="收到,再见"></input>
<label for="keywords_playlocal">播放本地歌曲口令:</label>

View File

@ -68,9 +68,8 @@ $(function(){
// 初始化显示
for (const key in data) {
if (data.hasOwnProperty(key)) {
const $element = $("#" + key);
if ($element.length && data[key] !== '') {
if ($element.length) {
if (data[key] === true) {
$element.val('true');
} else if (data[key] === false) {
@ -79,7 +78,6 @@ $(function(){
$element.val(data[key]);
}
}
}
}
autoSelectOne();

View File

@ -918,7 +918,7 @@ class XiaoMusicDevice:
self.cur_music = name
self.log.info(f"cur_music {self.cur_music}")
sec, url = await self.xiaomusic.get_music_sec_url(name)
await self.group_force_stop_xiaoai()
# await self.group_force_stop_xiaoai()
self.log.info(f"播放 {url}")
results = await self.group_player_play(url)
if all(ele is None for ele in results):
@ -933,6 +933,7 @@ class XiaoMusicDevice:
# 取消组内所有的下一首歌曲的定时器
self.cancel_group_next_timer()
# 设置下一首歌曲的播放定时器
sec = sec + self.config.delay_sec
await self.set_next_music_timeout(sec)
async def do_tts(self, value):
@ -941,7 +942,7 @@ class XiaoMusicDevice:
self.log.info("do_tts no value")
return
await self.group_force_stop_xiaoai()
# await self.group_force_stop_xiaoai()
await self.text_to_speech(value)
# 最大等8秒