Open fivestrong opened 8 years ago
你试试能不能用mpg123直接播放音乐
@kigawas 试了以下mpg123 可以正常播放音乐
@fivestrong 现在还有这个问题么?或者换个终端?
同样的问题 lxterminal和xfce4-terminal都一样
@kigawas 用yaourt 重新编译了一下,还是有问题,终端换了urxvt和deepin-terminal 都是这个问题,第一首ok第二首播放到一半就挂了。 1 archlinuxcn/netease-musicbox-git r414.8a72cc8-1 [installed] A sexy command line interface musicbox for NetEase based on Python 2 aur/mopidy-musicbox 2.3.0-1 (11) (0.66) Web Client for Mopidy Music Server and the Pi MusicBox 3 aur/netease-musicbox-git r363.995b132-1 installed: r414.8a72cc8-1 (0.44) A sexy command line interface musicbox for NetEase based on Python 话说能直接从git源码直接自己编译吗?不用pacman。
@fivestrong 你从aur编译它也是从github获取的最新版的代码
问题似乎是mpg123突然失去响应,你试试通过mpg123的命令行形式播放两首歌看有没有同样的问题
用mpg123听了半天,没有这个问题。
的确,我也遇到了。 研究了两天,好像是 mpg123 进程刚起来的时候就 defunct 了。
$ ps -ef | grep mpg123
yorks 4744 4735 0 15:35 pts/3 00:00:00 [mpg123] <defunct>
不知道是什么情况下才会引起 mpg123 defunct 掉。 于是自己加了个逻辑,如果是这种情况就重新起 mpg123 进程,是正常的, 后遗症是如果是播放了2,3s 的时候defunct 就会听到重复的 2,3s。 所以最好的办法是找到 mpg123 defunct 的原因, 对这个我没研究,就凑合用我自己的修改了。下面给出diff.
config.py:
git diff config.py
diff --git a/NEMbox/config.py b/NEMbox/config.py
index 464cafe..ef01300 100644
--- a/NEMbox/config.py
+++ b/NEMbox/config.py
@@ -38,6 +38,11 @@ class Config(Singleton):
'default': [],
'describe': 'The additional parameters when mpg123 start.'
},
+ 'mpg123_oops_restart': {
+ 'value': True,
+ 'default': True,
+ 'describe': 'Restart mpg123 to play the song when mpg123 process is oops(defunct).'
+ },
'aria2c_parameters': {
'value': [],
'default': [],
player.py:
git diff player.py
diff --git a/NEMbox/player.py b/NEMbox/player.py
index fdb9bbe..3cfda8b 100644
--- a/NEMbox/player.py
+++ b/NEMbox/player.py
@@ -53,6 +53,7 @@ class Player(object):
self.cache = Cache()
self.notifier = self.config.get_item('notifier')
self.mpg123_parameters = self.config.get_item('mpg123_parameters')
+ self.mpg123_oops_restart = self.config.get_item('mpg123_oops_restart')
self.end_callback = None
self.playing_song_changed_callback = None
@@ -82,6 +83,8 @@ class Player(object):
self.popen_handler.stdin.flush()
self.process_first = True
+ # flag for mpg123 oops
+ retry = False
while True:
if self.playing_flag is False:
break
@@ -118,9 +121,27 @@ class Player(object):
self.popen_handler.stdin.flush()
self.popen_handler.kill()
break
+ elif not strout:
+ log.warning('@NULL mpg123 already be killed??? Or mpg123 already dead?? retry it.')
+ log.debug('mpg123 <defunct> pid:%d'% self.popen_handler.pid)
+ if not self.mpg123_oops_restart:
+ time.sleep(0.1) # avoid log toooooo much
+ continue
+
+ try:
+ self.popen_handler.stdin.write(b'Q\n')
+ self.popen_handler.stdin.flush()
+ self.popen_handler.kill()
+ except Exception, e:
+ pass
+
+ retry = True
+ break
+
+
if self.playing_flag:
- self.next_idx()
+ if not retry:self.next_idx()
onExit()
return
@@ -195,7 +216,7 @@ class Player(object):
self.ui.build_playinfo(item['song_name'], item['artist'],
item['album_name'], item['quality'],
time.time())
- if self.notifier:
+ if self.notifier and self.playing_id != item['song_id']:
self.ui.notify('Now playing', item['song_name'],
item['album_name'], item['artist'])
self.playing_id = item['song_id']
哦,这个情况在之前的版本就会引起调到下一首曲子。
我也出现了 OSX 10.11.6
系统是archlinux的majaro i3wm ,下载最新版本的musicbox ➜ ~ yaourt musicbox 1 archlinuxcn/netease-musicbox-git r414.8a72cc8-1 [installed] A sexy command line interface musicbox for NetEase based on Python 2 aur/mopidy-musicbox 2.3.0-1 (11) (0.86) Web Client for Mopidy Music Server and the Pi MusicBox 3 aur/netease-musicbox-git r363.995b132-1 installed: r414.8a72cc8-1 (0.57) A sexy command line interface musicbox for NetEase based on Python
播放一首歌之后就卡住了,之后按任意键程序崩溃,ctrl + c 无效,无法关闭。 下面是报错提示: Traceback (most recent call last): File "/usr/bin/musicbox", line 9, inload_entry_point('NetEase-MusicBox==0.2.2.10','console_scripts', 'musicbox')()
File "/usr/lib/python2.7/site-packages/NEMbox/init.py", line 20, in startnembox_menu.start_fork(version)
File "/usr/lib/python2.7/site-packages/NEMbox/menu.py", line 172, in start_forkMenu().start()
File "/usr/lib/python2.7/site-packages/NEMbox/menu.py", line 421, in start'player_info']['idx'])
File "/usr/lib/python2.7/site-packages/NEMbox/player.py", line 240, in play_and_pauseself.pause()
File "/usr/lib/python2.7/site-packages/NEMbox/player.py", line 273, in pauseself.popen_handler.stdin.write('P\n')IOError: [Errno 32] Broken pipe