尝试从网络服务器运行mplayer时暂停

时间:2014-03-05 14:33:16

标签: mplayer

您好我正在使用python创建自己的用户界面。 在这个我目前运行mplayer从点击nohup(以免弄乱服务器运行),我想要做的是添加一个暂停按钮。

运行nohup时是否可以这样做,或者有更好的方法吗?

如此努力

os.system("nohup mplayer file.mp3 &")
只要我能找到,

就不允许暂停。

然后;

os.system("rm /tmp/mplayer")
os.system("mkfifo /tmp/mplayer")
os.system("nohup mplayer -slave -input file=/tmp/mplayer file.mp3 &")

然后使用;

创建我的暂停按钮
os.system("echo pause > /tmp/mplayer") ##click again to unplay
如果在新终端中键入

,但在播放时杀死我的网络服务器。因此无法在网络服务器上运行。

目前正在使用Flask / Python和jinja模板。

非常感谢

1 个答案:

答案 0 :(得分:0)

为什么你没有使用python-mplayer包装器来控制来自python的mplayer有什么特别的原因?此模块非常完整,可让您控制播放功能,包括暂停。

编辑: 对于非标准的mplayer二进制位置内省方法可能需要调用(基于wiki entry from official page

from mplayer import Player

# First, specify the correct path to the MPlayer executable
Player.exec_path = '/actual/path/to/the/mplayer-bin'

# Then, manually call the introspect() class method
Player.introspect()


# Since autospawn is True by default, no need to call player.spawn() manually
player = Player()

# Play a file
player.loadfile('/path/to/file.mkv')

# Pause playback
player.pause()