feat: 支持继续播放 (#171)
This commit is contained in:
parent
0543c92f37
commit
ba58d45d8b
@ -145,6 +145,9 @@ class Config:
|
|||||||
)
|
)
|
||||||
convert_to_mp3: bool = os.getenv("CONVERT_TO_MP3", "false").lower() == "true"
|
convert_to_mp3: bool = os.getenv("CONVERT_TO_MP3", "false").lower() == "true"
|
||||||
delay_sec: int = int(os.getenv("XIAOMUSIC_DELAY_SEC", 3)) # 下一首歌延迟播放秒数
|
delay_sec: int = int(os.getenv("XIAOMUSIC_DELAY_SEC", 3)) # 下一首歌延迟播放秒数
|
||||||
|
continue_play: bool = (
|
||||||
|
os.getenv("XIAOMUSIC_CONTINUE_PLAY", "false").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
def append_keyword(self, keys, action):
|
def append_keyword(self, keys, action):
|
||||||
for key in keys.split(","):
|
for key in keys.split(","):
|
||||||
|
@ -147,6 +147,12 @@ var vConsole = new window.VConsole();
|
|||||||
<option value="false" selected>false</option>
|
<option value="false" selected>false</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<label for="continue_play">启用继续播放(可能导致兼容性问题及歌曲无法完整播放):</label>
|
||||||
|
<select id="continue_play">
|
||||||
|
<option value="true">true</option>
|
||||||
|
<option value="false" selected>false</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
<label for="public_port">外网访问端口(0表示跟监听端口一致):</label>
|
<label for="public_port">外网访问端口(0表示跟监听端口一致):</label>
|
||||||
<input id="public_port" type="number" value="0"></input>
|
<input id="public_port" type="number" value="0"></input>
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ class XiaoMusic:
|
|||||||
self.music_path_depth = self.config.music_path_depth
|
self.music_path_depth = self.config.music_path_depth
|
||||||
self.remove_id3tag = self.config.remove_id3tag
|
self.remove_id3tag = self.config.remove_id3tag
|
||||||
self.convert_to_mp3 = self.config.convert_to_mp3
|
self.convert_to_mp3 = self.config.convert_to_mp3
|
||||||
|
self.continue_play = self.config.continue_play
|
||||||
|
|
||||||
def update_devices(self):
|
def update_devices(self):
|
||||||
self.device_id_did = {} # key 为 device_id
|
self.device_id_did = {} # key 为 device_id
|
||||||
@ -1178,9 +1179,14 @@ class XiaoMusicDevice:
|
|||||||
# 继续播放被打断的歌曲
|
# 继续播放被打断的歌曲
|
||||||
async def check_replay(self):
|
async def check_replay(self):
|
||||||
if self.isplaying() and not self.isdownloading():
|
if self.isplaying() and not self.isdownloading():
|
||||||
# 继续播放歌曲
|
if not self.config.continue_play:
|
||||||
self.log.info("现在继续播放歌曲")
|
# 重新播放歌曲
|
||||||
await self._play()
|
self.log.info("现在重新播放歌曲")
|
||||||
|
await self._play()
|
||||||
|
else:
|
||||||
|
self.log.info(
|
||||||
|
f"继续播放歌曲. self.config.continue_play:{self.config.continue_play}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
f"不会继续播放歌曲. isplaying:{self.isplaying()} isdownloading:{self.isdownloading()}"
|
f"不会继续播放歌曲. isplaying:{self.isplaying()} isdownloading:{self.isdownloading()}"
|
||||||
@ -1277,7 +1283,14 @@ class XiaoMusicDevice:
|
|||||||
ret = None
|
ret = None
|
||||||
try:
|
try:
|
||||||
audio_id = await self._get_audio_id(name)
|
audio_id = await self._get_audio_id(name)
|
||||||
if self.config.use_music_api:
|
if self.config.continue_play:
|
||||||
|
ret = await self.xiaomusic.mina_service.play_by_music_url(
|
||||||
|
device_id, url, _type=1, audio_id=audio_id
|
||||||
|
)
|
||||||
|
self.log.info(
|
||||||
|
f"play_one_url continue_play device_id:{device_id} ret:{ret} url:{url} audio_id:{audio_id}"
|
||||||
|
)
|
||||||
|
elif self.config.use_music_api:
|
||||||
ret = await self.xiaomusic.mina_service.play_by_music_url(
|
ret = await self.xiaomusic.mina_service.play_by_music_url(
|
||||||
device_id, url, audio_id=audio_id
|
device_id, url, audio_id=audio_id
|
||||||
)
|
)
|
||||||
@ -1295,6 +1308,8 @@ class XiaoMusicDevice:
|
|||||||
|
|
||||||
async def _get_audio_id(self, name):
|
async def _get_audio_id(self, name):
|
||||||
audio_id = 1582971365183456177
|
audio_id = 1582971365183456177
|
||||||
|
if not (self.config.use_music_api or self.config.continue_play):
|
||||||
|
return str(audio_id)
|
||||||
try:
|
try:
|
||||||
params = {
|
params = {
|
||||||
"query": name,
|
"query": name,
|
||||||
|
Loading…
Reference in New Issue
Block a user