Update of /cvsroot/freevo/freevo/src/audio/plugins In directory sc8-pr-cvs1:/tmp/cvs-serv733
Added Files: radio.py radioplayer.py Log Message: Start of Radio Support --- NEW FILE: radio.py --- #if 0 /* # ----------------------------------------------------------------------- # radio.py - a simple plugin to listen to radio # ----------------------------------------------------------------------- # $Id: radio.py,v 1.1 2003/08/27 15:30:12 mikeruelle Exp $ # # Notes: # need to have radio installed before using this plugin # to activate put the following in your local_conf.py # plugin.activate('audio.radioplayer') # plugin.activate('audio.radio') # RADIO_CMD='/usr/bin/radio' # RADIO_STATIONS = [ ('Sea FM', '90.9'), # ('Kiss 108', '108'), # ('Mix 98.5', '98.5'), # ('Magic 106', '106.7') ] # Todo: # # ----------------------------------------------------------------------- # $Log: radio.py,v $ # Revision 1.1 2003/08/27 15:30:12 mikeruelle # Start of Radio Support # # # ----------------------------------------------------------------------- # 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 # # ----------------------------------------------------------------------- */ #endif #python modules import os, popen2, fcntl, select, time #freevo modules import config, menu, rc, plugin, skin, util from audio.player import PlayerGUI import event as em from item import Item #get the sinfletons so we can add our menu and get skin info skin = skin.get_singleton() menuwidget = menu.get_singleton() TRUE = 1 FALSE = 0 # 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. class RadioItem(Item): def actions(self): """ return a list of actions for this item """ items = [ ( self.play , 'Listen to Station' ) ] return items def play(self, arg=None, menuw=None): print self.station+" "+str(self.station_index)+" "+self.name # self.parent.current_item = self 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 'RadioItem stop' self.player.stop() # this is the item for the main menu and creates the list # of commands in a submenu. class RadioMainMenuItem(Item): def actions(self): """ return a list of actions for this item """ items = [ ( self.create_stations_menu , 'stations' ) ] return items def create_stations_menu(self, arg=None, menuw=None): station_items = [] for rstation in config.RADIO_STATIONS: radio_item = RadioItem() radio_item.name = rstation[0] radio_item.station = rstation[1] radio_item.type = 'radio' radio_item.station_index = config.RADIO_STATIONS.index(rstation) radio_item.length = 0 radio_item.remain = 0 radio_item.elapsed = 0 station_items += [ radio_item ] if (len(station_items) == 0): station_items += [menu.MenuItem('No Stations found', menuwidget.goto_prev_page, 0)] station_menu = menu.Menu('Stations', station_items) rc.app(None) menuwidget.pushmenu(station_menu) menuwidget.refresh() # our plugin wrapper, just creates the main menu item and adds it. class PluginInterface(plugin.MainMenuPlugin): def items(self, parent): menu_items = skin.settings.mainmenu.items item = RadioMainMenuItem() item.name = 'Radio' if menu_items.has_key('radio') and menu_items['radio'].icon: item.icon = os.path.join(skin.settings.icon_dir, menu_items['radio'].icon) if menu_items.has_key('radio') and menu_items['radio'].image: item.image = menu_items['radio'].image item.parent = parent return [ item ] --- NEW FILE: radioplayer.py --- #if 0 /* # ----------------------------------------------------------------------- # radioplayer.py - the Freevo Radioplayer plugin for radio # ----------------------------------------------------------------------- # $Id: radioplayer.py,v 1.1 2003/08/27 15:30:12 mikeruelle Exp $ # # Notes: # Todo: # # ----------------------------------------------------------------------- # $Log: radioplayer.py,v $ # Revision 1.1 2003/08/27 15:30:12 mikeruelle # Start of Radio Support # # # # ----------------------------------------------------------------------- # 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 # # ----------------------------------------------------------------------- */ #endif import time, os import string import re import config # Configuration handler. reads config file. import util # Various utilities import rc import plugin from event import * DEBUG = config.DEBUG TRUE = 1 FALSE = 0 class PluginInterface(plugin.Plugin): """ player plugin for the radio player. Use radio player to play all radio stations. """ def __init__(self): # create the mplayer object plugin.Plugin.__init__(self) # register it as the object to play audio plugin.register(self, plugin.RADIO_PLAYER) self.mode = 'idle' def play(self, item, playerGUI): """ play a radioitem with radio player """ self.playerGUI = playerGUI self.item = item print 'RadioPlayer.play() %s' % self.item.station self.mode = 'play' mixer = plugin.getbyname('MIXER') mixer.setLineinVolume(config.TV_IN_VOLUME) mixer.setIgainVolume(config.TV_IN_VOLUME) mixer.setMicVolume(config.TV_IN_VOLUME) os.system('%s -qf %s' % (config.RADIO_CMD, self.item.station)) return None def stop(self): """ Stop mplayer and set thread to idle """ print 'Radio Player Stop' self.mode = 'stop' mixer = plugin.getbyname('MIXER') mixer.setLineinVolume(0) mixer.setIgainVolume(0) mixer.setMicVolume(0) os.system('%s -m' % config.RADIO_CMD) def is_playing(self): print 'Radio Player IS PLAYING?' return self.mode == 'play' def refresh(self): print 'Radio Player refresh' self.playerGUI.refresh() def eventhandler(self, event): """ 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 == AUDIO_PLAY_END or event == MENU_BACK_ONE_MENU: event = PLAY_END 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) ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Freevo-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog