Author: duncan
Date: Wed Jan 3 20:30:01 2007
New Revision: 8921
Modified:
branches/rel-1/freevo/src/audio/plugins/mplayer.py
Log:
[ 1587694 ] Show streaminfo in webradio
Patch from Jaap Struyk applied
Trailing whitespace has been removed
Modified: branches/rel-1/freevo/src/audio/plugins/mplayer.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/mplayer.py (original)
+++ branches/rel-1/freevo/src/audio/plugins/mplayer.py Wed Jan 3 20:30:01 2007
@@ -5,11 +5,11 @@
# $Id$
#
# Notes:
-# Todo:
+# Todo:
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
-# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
@@ -58,7 +58,7 @@
"""
the main class to control mplayer
"""
-
+
def __init__(self):
self.name = 'mplayer'
self.app_mode = 'audio'
@@ -78,7 +78,7 @@
return 1
return 2
-
+
def get_demuxer(self, filename):
DEMUXER_MP3 = 17
DEMUXER_OGG = 18
@@ -102,10 +102,10 @@
if filename and not os.path.isfile(filename):
return _('%s\nnot found!') % Unicode(item.url)
-
+
if not filename:
filename = item.url
-
+
# Build the MPlayer command
mpl = '--prio=%s %s -slave %s' % (config.MPLAYER_NICE,
config.MPLAYER_CMD,
@@ -124,7 +124,7 @@
is_playlist = False
if hasattr(item, 'is_playlist') and item.is_playlist:
is_playlist = True
-
+
if item.network_play and ( str(filename).endswith('m3u') or
str(filename).endswith('pls')):
is_playlist = True
@@ -133,34 +133,34 @@
if hasattr(item, 'reconnect') and item.reconnect:
extra_opts += ' -loop 0'
-
+
command = '%s -vo null -ao %s %s %s' % (mpl, config.MPLAYER_AO_DEV,
demux,
extra_opts)
if command.find('-playlist') > 0:
command = command.replace('-playlist', '')
-
+
command = command.replace('\n', '').split(' ')
if is_playlist:
command.append('-playlist')
-
+
command.append(filename)
self.plugins = plugin.get('mplayer_audio')
for p in self.plugins:
command = p.play(command, self)
-
+
if plugin.getbyname('MIXER'):
plugin.getbyname('MIXER').reset()
self.item = item
_debug_('MPlayer.play(): Starting cmd=%s' % command)
-
+
self.app = MPlayerApp(command, self)
return None
-
+
def stop(self):
"""
@@ -178,7 +178,7 @@
def refresh(self):
self.playerGUI.refresh()
-
+
def eventhandler(self, event, menuw=None):
"""
@@ -194,7 +194,7 @@
self.stop()
if self.playerGUI.try_next_player():
return True
-
+
if event == AUDIO_SEND_MPLAYER_CMD:
self.app.write('%s\n' % event.arg)
return True
@@ -214,8 +214,8 @@
else:
# everything else: give event to the items eventhandler
return self.item.eventhandler(event)
-
-
+
+
# ======================================================================
class MPlayerApp(childapp.ChildApp2):
@@ -244,7 +244,7 @@
def stop_event(self):
return Event(PLAY_END, self.stop_reason,
handler=self.player.eventhandler)
-
+
def stdout_cb(self, line):
if line.startswith("A:"): # get current time
m = self.RE_TIME_NEW(line)
@@ -269,21 +269,29 @@
# playing for only seconds
self.item.elapsed = int(timestrs[1])
else:
- m = self.RE_TIME(line) # Convert decimal
+ m = self.RE_TIME(line) # Convert decimal
if m:
self.item.elapsed = int(m.group(1))
if self.item.elapsed != self.elapsed:
self.player.refresh()
self.elapsed = self.item.elapsed
-
+
for p in self.elapsed_plugins:
p.elapsed(self.elapsed)
-
+
elif not self.item.elapsed:
for p in self.stdout_plugins:
p.stdout(line)
-
+
+ if line.startswith("ICY Info"):
+ titleKey = "StreamTitle='"
+ titleIndex = line.find(titleKey)
+ if titleIndex != -1:
+ titleStart = titleIndex + len(titleKey)
+ titleEnd = line.find("'", titleStart)
+ if titleEnd > titleStart:
+ self.item.info['artist'] = line[titleStart:titleEnd]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog