Author: duncan
Date: Wed Oct 18 22:55:24 2006
New Revision: 8417
Added:
branches/rel-1/freevo/src/audio/plugins/xmradio.py
branches/rel-1/freevo/src/audio/plugins/xmradioHELP
branches/rel-1/freevo/src/audio/plugins/xmradioplayer.py
Log:
Justin Wetherell's audio plugin for XM online
Added: branches/rel-1/freevo/src/audio/plugins/xmradio.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/audio/plugins/xmradio.py Wed Oct 18 22:55:24 2006
@@ -0,0 +1,163 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# xmradio.py - a simple plugin to listen to xmradio online
+# -----------------------------------------------------------------------
+# $Id: xmradio.py 5860 2004-07-10 12:33:43Z phishman $
+#
+# Notes:
+# need to have an XM Radio account with a username and password
+# to activate put the following in your local_conf.py
+# plugin.activate('audio.xmradio')
+# plugin.activate('audio.xmradioplayer')
+# XM_USER='Your user name'
+# XM_PASS='Your password'
+# XM_RATE='high'
+# XM_STATIONS = [ ('High Voltage', '202'),
+# ('Home Ice', '204'),
+# ('Music Lab', '51') ]
+# Todo:
+#
+# -----------------------------------------------------------------------
+# $Log$
+# Revision 1.0 2006/04/06 12:33:38 phishman3579
+# initial release
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2003 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
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# ----------------------------------------------------------------------- */
+
+
+#python modules
+import os, popen2, fcntl, select, time, re
+
+#freevo modules
+import config, menu, rc, plugin, util
+from audio.player import PlayerGUI
+from audio.audioitem import AudioItem
+from item import Item
+
+
+class XmRadioItem(AudioItem):
+ """
+ This is the class that actually runs the commands. Eventually
+ hope to add actions for different ways of running commands
+ and for displaying stdout and stderr of last command run.
+ """
+ def actions(self):
+ """
+ return a list of actions for this item
+ """
+ items = [ ( self.play , _( 'Listen to XM Station' ) ) ]
+ return items
+
+
+ def play(self, arg=None, menuw=None):
+ self.elapsed = 0
+
+ if not self.menuw:
+ self.menuw = menuw
+
+ self.player = PlayerGUI(self, menuw)
+ error = self.player.play()
+
+ if error and menuw:
+ AlertBox(text=error).show()
+ rc.post_event(rc.PLAY_END)
+
+ def stop(self, arg=None, menuw=None):
+ """
+ Stop the current playing
+ """
+ print 'XmRadioItem stop'
+ self.player.stop()
+
+
+
+class XmRadioMainMenuItem(Item):
+ """
+ this is the item for the main menu and creates the list
+ of commands in a submenu.
+ """
+ def __init__(self, parent):
+ Item.__init__(self, parent, skin_type='radio')
+ self.name = _( 'XM Radio' )
+
+
+ def actions(self):
+ """
+ return a list of actions for this item
+ """
+ return [ ( self.create_stations_menu , 'xm stations' ) ]
+
+
+ def create_stations_menu(self, arg=None, menuw=None):
+ string="rm -f /tmp/xmonline.cookies"
+ os.system(string)
+
+ string=('curl -s -c /tmp/xmonline.cookies -d "user_id=%s" -d "pword=%s"
"http://xmro.xmradio.com/xstream/login_servlet.jsp" >
/tmp/xmonlinelogin.out'%(config.XM_USER,config.XM_PASS))
+ os.system(string)
+
+ station_items = []
+ for rstation in config.XM_STATIONS:
+ string="rm -f /tmp/xmonlinechannel.out"
+ os.system(string)
+
+ string=('curl -s -b /tmp/xmonline.cookies -d ""
"http://player.xmradio.com/player/2ft/playMedia.jsp?ch=%s&speed=%s" >
/tmp/xmonlinestream.out'%(rstation[1],config.XM_RATE))
+ os.system(string)
+
+ string='egrep "<PARAM NAME=.FileName. VALUE="
/tmp/xmonlinestream.out > /tmp/xmurl.out'
+ os.system(string)
+
+ string='sed "s/.*<PARAM NAME=.FileName. VALUE="// /tmp/xmurl.out >
/tmp/xmurl2.out'
+ os.system(string)
+
+ string='sed "s/>.*//" /tmp/xmurl2.out > /tmp/xmurl3.out'
+ os.system(string)
+
+ file = open("/tmp/xmurl3.out","r")
+ text = file.readlines()
+ file.close()
+ for line in text:
+ radio_item = XmRadioItem(line,self,str(rstation[0]))
+ config.CONF.fbxine = '/usr/local/bin/xine'
+ station_items += [ radio_item ]
+ if (len(station_items) == 0):
+ station_items += [menu.MenuItem( _( 'No Xm Radio Stations found' ),
+ menwu.goto_prev_page, 0)]
+ station_menu = menu.Menu( _( 'Radio Stations' ), station_items)
+ rc.app(None)
+ menuw.pushmenu(station_menu)
+ menuw.refresh()
+
+
+
+class PluginInterface(plugin.MainMenuPlugin):
+ """
+ need to have an XM Radio account with a username and password
+ to activate put the following in your local_conf.py
+ plugin.activate('audio.xmradioplayer')
+ plugin.activate('audio.xmradio')
+ XM_CMD='xine'
+ XM_STATIONS = [ ('High Voltage', '202'),
+ ('Home Ice', '204'),
+ ('Music Lab', '51') ]
+ """
+ def items(self, parent):
+ return [ XmRadioMainMenuItem(parent) ]
Added: branches/rel-1/freevo/src/audio/plugins/xmradioHELP
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/audio/plugins/xmradioHELP Wed Oct 18 22:55:24 2006
@@ -0,0 +1,23 @@
+http://www.freevohelp.com/xmonline/index.html
+
+XMonline is a plugin for Freevo that allows the user to listen to live
streaming
+XM content with a valid xmonline account.
+
+Feel free to use the forum or you can also reach me via e-mail, look at main
page.
+
+Place the following files into src/audio/plugins/
+xmradio.py
+xmradioplayer.py
+
+Add the following variables into your local_conf.py
+plugin.activate('audio.xmradio')
+plugin.activate('audio.xmradioplayer')
+XM_CMD='mplayer'
+XM_USER='your xmonline user id (usually an e-mail address)'
+XM_PASS='your xmonline password'
+XM_RATE='high'
+XM_STATIONS = [
+ ('High Voltage', '202'),
+ ('Home Ice', '204'),
+ ('Music Lab', '51')
+]
Added: branches/rel-1/freevo/src/audio/plugins/xmradioplayer.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/audio/plugins/xmradioplayer.py Wed Oct 18
22:55:24 2006
@@ -0,0 +1,145 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# xmradioplayer.py - the Freevo XmRadioplayer plugin for radio
+# -----------------------------------------------------------------------
+# $Id: xmradioplayer.py 7274 2006-04-07 21:56:46Z phishman3579 $
+#
+# Notes:
+# Todo:
+#
+# -----------------------------------------------------------------------
+# $Log$
+# Revision 1.0 2006/04/07 00:24:20 phishman3579
+# initial release
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# 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
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# ----------------------------------------------------------------------- */
+
+
+import time, os
+import string
+import re
+import thread
+
+import config # Configuration handler. reads config file.
+import util # Various utilities
+import plugin
+
+from event import *
+from mplayer import MPlayerApp
+
+
+class PluginInterface(plugin.Plugin):
+ """
+ This is the player plugin for the radio. Basically it tunes all the
+ radio stations set in the radio plugin and does the interaction
+ between the radio command line program and freevo. please see the
+ audio.radio plugin for setup information
+
+ """
+ def __init__(self):
+ plugin.Plugin.__init__(self)
+
+ # register it as the object to play audio
+ plugin.register(XmRadioPlayer(), plugin.AUDIO_PLAYER, True)
+
+class XmRadioPlayer:
+
+ def __init__(self):
+ self.mode = 'idle'
+ self.name = 'xmradioplayer'
+ self.app_mode = 'audio'
+ self.app = None
+ self.starttime = 0
+
+ def rate(self, item):
+ """
+ How good can this player play the file:
+ 2 = good
+ 1 = possible, but not good
+ 0 = unplayable
+ """
+ if item.url.startswith('http://'):
+ return 2
+ return 0
+
+
+ def play(self, item, playerGUI):
+ """
+ play a radioitem with radio player
+ """
+ self.playerGUI = playerGUI
+ self.item = item
+ self.item.elapsed = 0
+ self.starttime = time.time()
+
+ self.mode = 'play'
+ mixer = plugin.getbyname('MIXER')
+ if mixer:
+ mixer.setLineinVolume(config.TV_IN_VOLUME)
+ mixer.setIgainVolume(config.TV_IN_VOLUME)
+ mixer.setMicVolume(config.TV_IN_VOLUME)
+ else:
+ print 'Xm Radio Player failed to find a mixer'
+ cmd=('%s -cache 100 -playlist %s' % (config.XM_CMD, self.item.url))
+ print(cmd)
+ self.app = MPlayerApp(cmd, self)
+ return None
+
+
+ def stop(self):
+ """
+ Stop mplayer
+ """
+ self.app.stop('quit\n')
+
+
+ def is_playing(self):
+ self.item.elapsed = int(time.time() - self.starttime)
+ return self.app.isAlive()
+
+
+ def refresh(self):
+ self.playerGUI.refresh()
+
+
+ def eventhandler(self, event, menuw=None):
+ """
+ eventhandler for mplayer control. If an event is not bound in this
+ function it will be passed over to the items eventhandler
+ """
+ print 'Radio Player event handler %s' % event
+ if event in ( STOP, PLAY_END, USER_END ):
+ self.playerGUI.stop()
+ return self.item.eventhandler(event)
+
+ else:
+ # everything else: give event to the items eventhandler
+ return self.item.eventhandler(event)
+
+ def __update_thread(self):
+ """
+ OSD update thread
+ """
+ while self.is_playing():
+ self.refresh()
+ time.sleep(0.3)
+
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog