Skip to content

沉浸式插件有办法自动退出沉浸式吗? #351

Description

@mylovexx

我想让本地音乐播放器仅播放一首歌曲就停止,所以改写了MusicPlayer类的play函数:

def play(self, idx=None):
logger.debug("MusicPlayer play")
if idx == None:
path = self.playlist[self.idx]
super().stop()
super().play(path, False, self.next)
else:
path = self.playlist[idx]
super().stop()
super().play(path, False, self.pause)

但是报了如下错误:

2025-02-25 23:08:40,695 - asyncio - ERROR - Exception in callback SoxPlayer.executeOnCompleted(True, >)
handle: <Handle SoxPlayer.executeOnCompleted(True, >)>
Traceback (most recent call last):
File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/pi/intelligent_screen/robot/Player.py", line 91, in executeOnCompleted
res and onCompleted and onCompleted()
^^^^^^^^^^^^^
File "/home/pi/intelligent_screen/robot/Player.py", line 215, in pause
os.kill(self.proc.pid, signal.SIGSTOP)
ProcessLookupError: [Errno 3] No such process

之后在唤醒wukong-robot的时候又出现了如下错误:

2025-02-25 23:11:45,195 - robot.Player - INFO - 寮€濮嬫挱鏀鹃煶棰戯細/home/pi/intelligent_screen/static/beep_hi.wav
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/intelligent_screen/wukong.py", line 98, in run
detector.initDetector(self)
File "/home/pi/intelligent_screen/robot/detector.py", line 60, in initDetector
wukong.conversation.interrupt()
File "/home/pi/intelligent_screen/robot/Conversation.py", line 111, in interrupt
self.brain.pause()
File "/home/pi/intelligent_screen/robot/Brain.py", line 117, in pause
plugin.pause()
File "/home/pi/intelligent_screen/plugins/LocalPlayer.py", line 98, in pause
self.player.pause()
File "/home/pi/intelligent_screen/robot/Player.py", line 215, in pause
os.kill(self.proc.pid, signal.SIGSTOP)
ProcessLookupError: [Errno 3] No such process

请问有好的解决办法吗?另外看沉浸式插件代码如果用户不输入退出命令的话,插件自己完成任务后似乎无法主动退出沉浸式状态,不知我的理解是否正确,谢谢!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions