Lines 63-69
Link Here
|
63 |
|
63 |
|
64 |
# ------------------------------------------ |
64 |
# ------------------------------------------ |
65 |
XTERM = re.search("rxvt|xterm", os.environ["TERM"]) |
65 |
XTERM = re.search("rxvt|xterm", os.environ["TERM"]) |
66 |
CONTROL_FIFO = "/var/tmp/cplay_control" |
66 |
CONTROL_FIFO = "%s/cplay-control-%s" % (os.environ.get("TMPDIR", "/tmp"), os.environ["USER"]) |
67 |
|
67 |
|
68 |
# ------------------------------------------ |
68 |
# ------------------------------------------ |
69 |
def which(program): |
69 |
def which(program): |
Lines 906-916
Link Here
|
906 |
|
906 |
|
907 |
def command_change_viewpoint(self, klass=PlaylistEntry): |
907 |
def command_change_viewpoint(self, klass=PlaylistEntry): |
908 |
if not globals().get("ID3"): |
908 |
if not globals().get("ID3"): |
|
|
909 |
global ID3, ogg, codecs |
910 |
have_meta = 0 |
909 |
try: |
911 |
try: |
910 |
global ID3, ogg, codecs |
912 |
import ID3 |
911 |
import ID3, ogg.vorbis, codecs |
913 |
have_meta = 1 |
|
|
914 |
except ImportError: |
915 |
pass |
916 |
try: |
917 |
import ogg.vorbis, codecs |
918 |
have_meta = 1 |
919 |
except ImportError: |
920 |
pass |
921 |
if have_meta: |
912 |
klass.vps.append([_("metadata"), klass.vp_metadata]) |
922 |
klass.vps.append([_("metadata"), klass.vp_metadata]) |
913 |
except ImportError: pass |
|
|
914 |
TagListWindow.command_change_viewpoint(self, klass) |
923 |
TagListWindow.command_change_viewpoint(self, klass) |
915 |
|
924 |
|
916 |
def get_title(self): |
925 |
def get_title(self): |
Lines 962-970
Link Here
|
962 |
try: |
971 |
try: |
963 |
if os.path.isdir(pathname): |
972 |
if os.path.isdir(pathname): |
964 |
app.status(_("Working...")) |
973 |
app.status(_("Working...")) |
965 |
self.add_dir(pathname) |
974 |
self.add_dir(os.path.abspath(pathname)) |
966 |
elif VALID_PLAYLIST(pathname): |
975 |
elif VALID_PLAYLIST(pathname): |
967 |
self.add_playlist(pathname) |
976 |
self.add_playlist(pathname) |
|
|
977 |
elif os.path.isfile(pathname): |
978 |
self.append(PlaylistEntry(os.path.abspath(pathname))) |
968 |
else: |
979 |
else: |
969 |
pathname = self.fix_url(pathname) |
980 |
pathname = self.fix_url(pathname) |
970 |
self.append(PlaylistEntry(pathname)) |
981 |
self.append(PlaylistEntry(pathname)) |
Lines 1301-1306
Link Here
|
1301 |
self.set_position(head, head+tail, [head, tail]) |
1312 |
self.set_position(head, head+tail, [head, tail]) |
1302 |
|
1313 |
|
1303 |
# ------------------------------------------ |
1314 |
# ------------------------------------------ |
|
|
1315 |
class MplayerOffsetPlayer(Player): |
1316 |
re_progress = re.compile("(\d+).*\sof (\d+)") |
1317 |
|
1318 |
def parse_buf(self): |
1319 |
match = self.re_progress.search(self.buf) |
1320 |
if match: |
1321 |
s1, s2 = map(string.atoi, match.groups()) |
1322 |
head, tail = s1, s2-s1 |
1323 |
self.set_position(head, head+tail, [head,tail]) |
1324 |
|
1325 |
# ------------------------------------------ |
1304 |
class NoOffsetPlayer(Player): |
1326 |
class NoOffsetPlayer(Player): |
1305 |
|
1327 |
|
1306 |
def parse_buf(self): |
1328 |
def parse_buf(self): |
Lines 1334-1341
Link Here
|
1334 |
# ------------------------------------------ |
1356 |
# ------------------------------------------ |
1335 |
class FIFOControl: |
1357 |
class FIFOControl: |
1336 |
def __init__(self): |
1358 |
def __init__(self): |
1337 |
try: self.fd = open(CONTROL_FIFO, "rb+", 0) |
|
|
1338 |
except: self.fd = None |
1339 |
self.commands = {"pause" : app.toggle_pause, |
1359 |
self.commands = {"pause" : app.toggle_pause, |
1340 |
"next" : app.next_song, |
1360 |
"next" : app.next_song, |
1341 |
"prev" : app.prev_song, |
1361 |
"prev" : app.prev_song, |
Lines 1346-1351
Link Here
|
1346 |
"volup" : app.inc_volume, |
1366 |
"volup" : app.inc_volume, |
1347 |
"voldown" : app.dec_volume, |
1367 |
"voldown" : app.dec_volume, |
1348 |
"quit" : app.quit} |
1368 |
"quit" : app.quit} |
|
|
1369 |
self.fd = None |
1370 |
try: |
1371 |
if os.path.exists(CONTROL_FIFO): |
1372 |
os.unlink(CONTROL_FIFO) |
1373 |
os.mkfifo(CONTROL_FIFO, 0600) |
1374 |
self.fd = open(CONTROL_FIFO, "rb+", 0) |
1375 |
except IOError: |
1376 |
# warn that we're disabling the fifo because someone raced us? |
1377 |
return |
1349 |
|
1378 |
|
1350 |
def handle_command(self): |
1379 |
def handle_command(self): |
1351 |
command = string.strip(self.fd.readline()) |
1380 |
command = string.strip(self.fd.readline()) |
Lines 1419-1424
Link Here
|
1419 |
XTERM and sys.stderr.write("\033]0;%s\a" % "xterm") |
1448 |
XTERM and sys.stderr.write("\033]0;%s\a" % "xterm") |
1420 |
tty and tty.tcsetattr(sys.stdin.fileno(), tty.TCSADRAIN, self.tcattr) |
1449 |
tty and tty.tcsetattr(sys.stdin.fileno(), tty.TCSADRAIN, self.tcattr) |
1421 |
print |
1450 |
print |
|
|
1451 |
# remove temporary files |
1452 |
try: |
1453 |
if os.path.exists(CONTROL_FIFO): os.unlink(CONTROL_FIFO) |
1454 |
except IOError: |
1455 |
pass |
1422 |
|
1456 |
|
1423 |
def run(self): |
1457 |
def run(self): |
1424 |
while 1: |
1458 |
while 1: |
Lines 1615-1621
Link Here
|
1615 |
if opt == "-v": app.mixer("toggle") |
1649 |
if opt == "-v": app.mixer("toggle") |
1616 |
if args or playlist: |
1650 |
if args or playlist: |
1617 |
for i in args or playlist: |
1651 |
for i in args or playlist: |
1618 |
app.win_playlist.add(os.path.abspath(i)) |
1652 |
app.win_playlist.add(i) |
1619 |
app.win_tab.change_window() |
1653 |
app.win_tab.change_window() |
1620 |
app.run() |
1654 |
app.run() |
1621 |
except SystemExit: |
1655 |
except SystemExit: |
Lines 1627-1641
Link Here
|
1627 |
|
1661 |
|
1628 |
# ------------------------------------------ |
1662 |
# ------------------------------------------ |
1629 |
PLAYERS = [ |
1663 |
PLAYERS = [ |
1630 |
FrameOffsetPlayer("ogg123 -q -v -k %d %s", "\.ogg$"), |
1664 |
FrameOffsetPlayer("ogg123 -q -v -k %d %s", "\.(ogg|flac)$"), |
1631 |
FrameOffsetPlayer("splay -f -k %d %s", "(^http://|\.mp[123]$)", 38.28), |
1665 |
FrameOffsetPlayer("splay -f -k %d %s", "(^http://|\.mp[123]$)", 38.28), |
1632 |
FrameOffsetPlayer("mpg123 -q -v -k %d %s", "(^http://|\.mp[123]$)", 38.28), |
1666 |
FrameOffsetPlayer("mpg123 -q -v -k %d %s", "(^http://|\.mp[123]$)", 38.28), |
1633 |
FrameOffsetPlayer("mpg321 -q -v -k %d %s", "(^http://|\.mp[123]$)", 38.28), |
1667 |
FrameOffsetPlayer("mpg321 -q -v -k %d %s", "(^http://|\.mp[123]$)", 38.28), |
1634 |
TimeOffsetPlayer("madplay -v --display-time=remaining -s %d %s", "\.mp[123]$"), |
1668 |
TimeOffsetPlayer("madplay -v --display-time=remaining -s %d %s", "\.mp[123]$"), |
|
|
1669 |
MplayerOffsetPlayer("mplayer -vo null -noconsolecontrols -ss %d %s", "\.(mp[123]|ogg|flac|wav|aiff|wma)$"), |
1635 |
NoOffsetPlayer("mikmod -q -p0 %s", "\.(mod|xm|fm|s3m|med|col|669|it|mtm)$"), |
1670 |
NoOffsetPlayer("mikmod -q -p0 %s", "\.(mod|xm|fm|s3m|med|col|669|it|mtm)$"), |
1636 |
NoOffsetPlayer("xmp -q %s", "\.(mod|xm|fm|s3m|med|col|669|it|mtm|stm)$"), |
1671 |
NoOffsetPlayer("xmp -q %s", "\.(mod|xm|fm|s3m|med|col|669|it|mtm|stm)$"), |
1637 |
NoOffsetPlayer("play %s", "\.(aiff|au|cdr|mp3|ogg|wav)$"), |
1672 |
NoOffsetPlayer("play %s", "\.(aiff|au|cdr|mp3|ogg|wav)$"), |
1638 |
NoOffsetPlayer("speexdec %s", "\.spx$") |
1673 |
NoOffsetPlayer("speexdec %s", "\.spx$"), |
|
|
1674 |
NoOffsetPlayer("mplayer -noconsolecontrols -playlist %s", "\.(ram|pls|asx)$") |
1639 |
] |
1675 |
] |
1640 |
|
1676 |
|
1641 |
def VALID_SONG(name): |
1677 |
def VALID_SONG(name): |