Created
May 18, 2012 22:59
-
-
Save yourcelf/2728011 to your computer and use it in GitHub Desktop.
Revisions
-
yourcelf revised this gist
May 18, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ #!/usr/bin/env python import sys import time import subprocess -
yourcelf renamed this gist
May 18, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
yourcelf revised this gist
May 18, 2012 . 1 changed file with 36 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,35 @@ import sys import time import subprocess def main(vid, aud): try: vidproc = subprocess.Popen(["mplayer", vid], stdin=subprocess.PIPE) audproc = subprocess.Popen(["mplayer", aud], stdin=subprocess.PIPE) while True: key = getch() if ord(key) == 3: raise KeyboardInterrupt elif key == 'd': print "Delaying video..." vidproc.stdin.write(' ') time.sleep(0.1) vidproc.stdin.write(' ') elif key == 'a': print "Delaying audio..." audproc.stdin.write(' ') time.sleep(0.1) audproc.stdin.write(' ') else: vidproc.stdin.write(key) audproc.stdin.write(key) except KeyboardInterrupt: pass finally: vidproc.kill() audproc.kill() class _Getch: """Gets a single character from standard input. Does not echo to the screen.""" @@ -25,7 +57,6 @@ class _GetchUnix: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) return ch class _GetchWindows: def __init__(self): import msvcrt @@ -34,5 +65,7 @@ class _GetchWindows: import msvcrt return msvcrt.getch() getch = _Getch() if __name__ == "__main__": main(sys.argv[1], sys.argv[2]) -
yourcelf created this gist
May 18, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ class _Getch: """Gets a single character from standard input. Does not echo to the screen.""" def __init__(self): try: self.impl = _GetchWindows() except ImportError: self.impl = _GetchUnix() def __call__(self): return self.impl() class _GetchUnix: def __init__(self): import tty, sys def __call__(self): import sys, tty, termios fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) ch = sys.stdin.read(1) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) return ch class _GetchWindows: def __init__(self): import msvcrt def __call__(self): import msvcrt return msvcrt.getch() getch = _Getch()