0

Hi i am creating my own user interface using python. In this i currently run mplayer from a click with nohup (so as not to mess up the server running), what i would like to do is add a pause button.

Is this possible when running nohup or is there a better way to do it?

so trying

os.system("nohup mplayer file.mp3 &")

does not allow a pause as far as i could find.

then;

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

My pause button is then created using;

os.system("echo pause > /tmp/mplayer") ##click again to unplay

works if typed in new terminal but kills my webserver whilst playing. So does not work from webserver.

Currently working with Flask/Python and jinja templates.

Many thanks

bighead85
  • 71
  • 1
  • 4
  • 10

1 Answers1

0

Is there any specific reason why you are not using the python-mplayer wrapper to control mplayer from python? This module is pretty complete and gives you control over the playback functions including pausing.

EDIT: for non-standard mplayer binary location introspection method may need to be called (based on 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()
Mr. Girgitt
  • 2,853
  • 1
  • 19
  • 22
  • I have never seen this before, sounds perfect but struggling to get it working (the documentation seems somewhat lacking). – bighead85 Mar 05 '14 at 15:09
  • I have never used it on linux however should have some examples for windows if your are interested. – Mr. Girgitt Mar 05 '14 at 15:10
  • would be great, my biggest issue is how to merge it with my existing project. ie where to drop mplayer folder etc so i can import it into my scripts. – bighead85 Mar 05 '14 at 15:17
  • you can put the executable wherever you want just set the `exec_path` class property to point to the executable before instantiating the player object. Have a look here: http://code.google.com/p/python-mplayer/wiki/Player and modify the exec_path the same way cmd_prefix is modified in the example. By default the wrapper searches for the executable in the working directory if I remember right. – Mr. Girgitt Mar 05 '14 at 15:21
  • I thought i was getting my head round python but this has me stumped. In linux you simple type 'mplayer file.mp3' to play it. So struggling, will keep going though because if i can make this work it should make the rest easier. Cheers – bighead85 Mar 05 '14 at 16:40
  • you may need to call `introspect()` method if mplayer binary is somewhere else than default for the module. – Mr. Girgitt Mar 05 '14 at 17:52