def Stop(self): self.mixer.stop() self.xine.stop() rc.app(self.prev_app) rc.post_event(PLAY_END) _debug_("IVTV_XINE_TV: Stopped '%s' app" % self.mode)
def Play(self, mode, tuner_channel=None): """ play with xine """ if not tuner_channel: tuner_channel = self.fc.getChannel() if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() rc.app(self) same_channel = self.last_channel == tuner_channel # If it's the same channel as last time and we have come back to it after # more than 2 minutes start at the end of the buffer, otherwise jump # straight back in where we left off. if same_channel: if (time.time() - self.stop_time) > 120.0: start_at_end = True else: start_at_end = False else: self.change_channel(tuner_channel) start_at_end = True if start_at_end: self.start_slave_server_at_end = True if same_channel: self.__change_state(STATE_PLAYING) else: self.__change_state(STATE_PLAYING) return None
def Stop(self, channel_change=0): mixer = plugin.getbyname('MIXER') if mixer and not channel_change: mixer.setLineinVolume(0) mixer.setMicVolume(0) mixer.setIgainVolume(0) # Input on emu10k cards. self.app.stop('quit\n') rc.app(self.prev_app) if osd.focused_app() and not channel_change: osd.focused_app().show() if os.path.exists('/tmp/freevo.wid'): os.unlink('/tmp/freevo.wid') if config.MPLAYER_OLDTVCHANNELCHANGE: lastchanfile = os.path.join(config.FREEVO_CACHEDIR, 'lastchan') lcfp = open(lastchanfile, "w") lastchan = self.fc.getChannel() lastchannum = self.fc.getChannelNum() lcfp.write(str(lastchan)) lcfp.write('\n') lcfp.write(str(lastchannum)) lcfp.write('\n') lcfp.close()
def show(self): if not self.visible: self.visible = 1 self.refresh(reload=1) for callback in copy.copy(self.show_callbacks): callback() rc.app(None)
def eventhandler(self, event, menuw=None): '''eventhandler''' if event == 'MENU_BACK_ONE_MENU': rc.app(None) self.menuw.show() return True elif event == 'MENU_SELECT': # toggle mpc off on execMPC("mpc toggle", "") skin.draw('mpd', self) return True elif event in ('MENU_DOWN', 'MENU_RIGHT'): # Skip to the next track. print execMPC("mpc next", "") skin.draw('mpd', self) return True elif event in ('MENU_UP', 'MENU_LEFT'): # Move to the previous track. execMPC("mpc prev", "") skin.draw('mpd', self) return True return False
def eventhandler(self, event, menuw=None): '''eventhandler''' if event == 'MENU_BACK_ONE_MENU': rc.app(None) self.menuw.show() return True elif event == 'MENU_SELECT': # TODO: update the current forecast data, and refresh self.weather.getForecast(force=1) skin.clear() skin.draw('weather', self) return True elif event in ('MENU_DOWN', 'MENU_RIGHT'): # Fire up the next skin self.nextSkin() skin.draw('weather', self) return True elif event in ('MENU_UP', 'MENU_LEFT'): # Fire up the previous skin self.prevSkin() skin.draw('weather', self) return True return False
def stop(self): """ Stop xine """ if self.app: self.app.stop('quit\n') rc.app(None)
def __change_state(self, new_state): """ Internal function to move to a new state. If new_state is different to the current state, set self.state to new_state and perform any state initialisation for the new state. """ if self.state == new_state: # No change in state nothing todo! return _debug_('Changing state from %s to %s' % (self.state, new_state)) self.state = new_state # State Initialisation code if self.state == STATE_IDLE: rc.app(None) rc.post_event(PLAY_END) self.udp_receiver.send_events = False elif self.state == STATE_TUNING: self.start_slave_server_at_end = True elif self.state == STATE_BUFFERING: self.wait_for_data_count = WAIT_FOR_DATA_COUNT elif self.state == STATE_PLAYING: self.slave_server.reader_at_end = self.start_slave_server_at_end self.slave_server.end_offset = self.udp_receiver.average_pps * WAIT_FOR_DATA_COUNT * 188 self.mrl_index = 0 self.app = childapp.ChildApp2(self.command) self.start_slave_server_at_end = False self.__draw_state_screen()
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.url = 'radio://' + str(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 radio_item.info = { 'album': '', 'artist': '', 'trackno': '', 'title': '' } station_items += [radio_item] if (len(station_items) == 0): station_items += [ menu.MenuItem(_('No 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()
def getheadlines(self, arg=None, menuw=None): headlines = [] rawheadlines = [] rawheadlines = self.getsiteheadlines() for title, link, description in rawheadlines: mi = menu.MenuItem('%s' % title, self.show_details, 0) mi.arg = (mi, menuw) mi.link = link description = description.replace('\n\n', '&#xxx;').replace('\n', ' ').\ replace('&#xxx;', '\n') description = description.replace('<p>', '\n').replace('<br>', '\n') description = description.replace('<p>', '\n').replace('<br/>', '\n') description = description + '\n \n \nLink: ' + link description = util.htmlenties2txt(description) mi.description = re.sub('<.*?>', '', description) headlines.append(mi) if (len(headlines) == 0): headlines += [ menu.MenuItem(_('No Headlines found'), menuw.goto_prev_page, 0) ] headlines_menu = menu.Menu(_('Headlines'), headlines) rc.app(None) menuw.pushmenu(headlines_menu) menuw.refresh()
def create_stations_menu(self, arg=None, menuw=None): lfm_items = [] if len(config.LASTFM_SESSION) > 5: for lfm_station in config.LASTFM_LOCATIONS: lfm_item = LastFMItem() lfm_item.name = lfm_station[0] lfm_item.station = urllib.quote_plus(lfm_station[1]) lfm_item.url = self.stream_url lfm_item.type = 'audio' lfm_item.mplayer_options = '' lfm_item.filename = '' lfm_item.network_play = 1 lfm_item.station_index = config.LASTFM_LOCATIONS.index( lfm_station) lfm_item.length = 0 lfm_item.remain = 0 lfm_item.elapsed = 0 lfm_item.info = { 'album': '', 'artist': '', 'trackno': '', 'title': '' } lfm_items += [lfm_item] if (len(lfm_items) == 0): lfm_items += [ menu.MenuItem(_('Invalid LastFM Session!'), menuw.goto_prev_page, 0) ] lfm_menu = menu.Menu(_('Last FM'), lfm_items) rc.app(None) menuw.pushmenu(lfm_menu) menuw.refresh()
def play(self, options, item): """ play a videoitem with vlc """ self.options = options self.item = item mode = item.mode url = item.url self.item_info = None self.item_length = -1 self.item.elapsed = 0 try: _debug_('Vlc.play(): url=%s' % url) except UnicodeError: _debug_('Vlc.play(): [non-ASCII data]') if config.VLC_OPTIONS: vlc_options = config.VLC_OPTIONS command = self.cmd + ' ' + vlc_options + ' --intf dummy -f --key-quit=esc "%s"' % url rc.app(self) self.app = childapp.ChildApp2(command) return None
def getheadlines(self, arg=None, menuw=None): """ this returns a menu with VideoItems for each headline """ headlines = [] rawheadlines = [] rawheadlines = self.getsiteheadlines() for title, link, description in rawheadlines: # create a VideoItem for each headline mi = VideoItem(link, self.parent) mi.name = title description = description.replace('\n\n', '&#xxx;').replace('\n', ' ').\ replace('&#xxx;', '\n') description = description.replace('<p>', '\n').replace('<br>', '\n') description = description.replace('<p>', '\n').replace('<br/>', '\n') description = description + '\n \n \nLink: ' + link description = util.htmlenties2txt(description) mi.plot = re.sub('<.*?>', '', description) headlines.append(mi) # create the menu if (len(headlines) == 0): headlines += [ menu.MenuItem(_('No Headlines found'), menuw.goto_prev_page, 0) ] headlines_menu = menu.Menu(_('Headlines'), headlines) rc.app(None) menuw.pushmenu(headlines_menu) menuw.refresh()
def dock(self): if rc.app() != self.player.eventhandler: rc.app(self.player) # get the rect from skin # XXX someone with better knowlegde of the # skin code should take a look at this imgarea = skin.areas['view'] c = imgarea.calc_geometry(imgarea.layout.content, copy_object=True) w = c.width - 2*c.spacing h = c.height - 2*c.spacing x = c.x + c.spacing y = c.y + c.spacing # check if the view-area has a rectangle try: r = c.types['default'].rectangle x -= r.x y -= r.y w += 2*r.x h += 2*r.y except: pass self.visual.set_resolution(x, y, w, h, 0, False)
def create_podcast_menu(self, arg=None, menuw=None): popup = PopupBox(text=_('Fetching podcasts...')) popup.show() podcast_menu_items = [] for location in config.APODCAST_LOCATIONS: url = location[1] image_path = config.APODCAST_DIR + '/' + location[ 0] + '/' + 'cover.jpg' if self.check_logo(image_path): p = podcast() p.open_rss(url) p.rss_title() name = p.rss_title image_url = p.rss_image self.download(image_url, image_path) if (len(config.APODCAST_DIR) == 0): podcast_items += [ menu.MenuItem(_('Set APODCAST_DIR in local_conf.py'), menwu.goto_prev_page, 0) ] podcast_menu_items += [ menu.MenuItem(_(location[0]), action=self.create_podcast_submenu, arg=location, image=image_path) ] popup.destroy() podcast_main_menu = menu.Menu(_('AUDIO PODCAST'), podcast_menu_items) rc.app(None) menuw.pushmenu(podcast_main_menu) menuw.refresh()
def eventhandler(self, event, menuw=None): """eventhandler""" _debug_('eventhandler(event=%s, menuw=%r)' % (event, menuw), 2) if event == 'MENU_BACK_ONE_MENU': rc.app(None) self.menuw.show() return True elif event == 'MENU_SELECT': self.weather.getForecast(force=1) skin.clear() skin.draw('oneclick', self) return True elif event in ('MENU_DOWN', 'MENU_RIGHT'): self.nextSkin() skin.draw('oneclick', self) return True elif event in ('MENU_UP', 'MENU_LEFT'): self.prevSkin() skin.draw('oneclick', self) return True return False
def onchoose_node(self, arg=None, menuw=None): """ browse through a tree specification """ tree = arg[0] data = arg[1] title = '-'.join(data) mylistofitems = [] if len(tree.spec) -1 <> len(data): #non-tracks for tree_item, count in tree.execute(data): mylistofitems.append( menu.MenuItem("%s(%i)" % \ (tree_item, count), action=self.onchoose_node, arg=[tree, data + [tree_item]])) else: #tracks self.onchoose_last_node(tree, data, menuw) return #should be impossible? if (len(mylistofitems) == 0): mylistofitems += [menu.MenuItem(_('No Objects found'), menuw.back_one_menu, 0)] myobjectmenu = menu.Menu(title, mylistofitems) #reload_func=menuw.back_one_menu ) rc.app(None) menuw.pushmenu(myobjectmenu) menuw.refresh()
def unselect(self): self.callHook('stop') rc.app(None) self.menuw.show() self.switch.saveAudioBalance() self.switch.setAudioBalance(0) self.switch.reset() self.switch.enableMixerReset()
def stop(self): global _player_ _player_ = None self.player.stop() self.running = False if self.visible: rc.app(None)
def fullscreen(self): if self.player.playerGUI.visible: self.player.playerGUI.hide() self.visual.set_fullscreen() self.visual.set_message(self.item_info()) skin.clear() rc.app(self)
def create_cool_menu(self, arg=None, menuw=None): myitems = [] myitems += [menu.MenuItem(_('Cool Choice1'), action=self.doChoice1)] myitems += [menu.MenuItem(_('Cool Choice2'), action=self.doChoice2)] cool_menu = menu.Menu(_('Cool Menu'), myitems) rc.app(None) menuw.pushmenu(cool_menu) menuw.refresh()
def create_cool_menu(self, arg=None, menuw=None): myitems = [] myitems += [menu.MenuItem(_('Cool Choice1'), action=self.doChoice1)] myitems += [menu.MenuItem(_('Cool Choice2'), action=self.doChoice2)] cool_menu = menu.Menu( _( 'Cool Menu' ), myitems) rc.app(None) menuw.pushmenu(cool_menu) menuw.refresh()
def chapter(self): if self.schapter == None: rc.app(self) rc.set_context('input') self.pop = PopupBox(_('Choose title to play. <1-9>')) self.pop.show() else: self.play()
def stop(self): self.app.stop() rc.app(None) if plugin.is_active('joy'): try: plugin.getbyname('JOY').enable(TRUE) except Exception, e: print 'getbyname(\'JOY\')', e
def Stop(self, channel_change=0): mixer = plugin.getbyname('MIXER') if mixer and not channel_change: mixer.setLineinVolume(0) mixer.setMicVolume(0) mixer.setIgainVolume(0) # Input on emu10k cards. self.app.stop() rc.app(self.prev_app)
def fullscreen(self): _debug_('fullscreen()', 2) if self.player.playerGUI.visible: self.player.playerGUI.hide() self.visual.set_fullscreen() self.visual.set_info(self.item_info(), 10) skin.clear() rc.app(self)
def noview(self): if rc.app() != self.player.eventhandler: rc.app(self.player) if self.visual: self.stop_visual() if not self.player.playerGUI.visible: self.player.playerGUI.show()
def eventhandler(self, event, menuw=None): """ eventhandler """ if event in ('MENU_SELECT', 'MENU_BACK_ONE_MENU'): rc.app(None) self.menuw.show() return True return False
def stop(self, channel_change=0): """ Stop xine """ if self.app: self.app.stop('quit\n') rc.app(None) if not channel_change: pass
def eventhandler(self, event, menuw=None): if event == em.STOP: self.stop() rc.app(None) if not menuw == None: menuw.refresh(reload=1) # give the event to the next eventhandler in the list return Item.eventhandler(self, event, menuw)
def poll(self): """ clear the osd after 2 seconds """ if self.message: self.message = '' if not rc.app() or not skin.get_singleton().force_redraw: skin.redraw() elif hasattr(rc.app(), 'im_self') and hasattr(rc.app().im_self, 'redraw'): rc.app().im_self.redraw()
def stop(self): """ Stop vlc """ if not self.app: return self.app.kill(2) rc.app(None) self.app = None
def stop(self): _debug_('stop()', 2) self.app.stop() rc.app(None) rc.resume() if plugin.is_active('joy'): try: plugin.getbyname('JOY').enable(TRUE) except Exception, e: _debug_('getbyname(\'JOY\')', e, DWARNING)
def select(self, arg=None, menuw=None): """Make this channel active on the uvswitch, and make us the current event handler. """ self.callHook('start') self.switch.setChannel(self.channel, False) self.switch.disableMixerReset() self.switch.restoreAudioBalance() menuw.hide() self.menuw = menuw rc.app(self)
def dock(self): logger.debug('dock()') self.mpvgoom.mode = MpvMode.DOCK if rc.app() != self.player.eventhandler: rc.app(self.player) self.mpvgoom.set_dock() if not self.player.playerGUI.visible: osd.active = True skin.resume() self.player.playerGUI.show()
def fullscreen(self): logger.debug('fullscreen()') self.mpvgoom.mode = MpvMode.FULL if self.player.playerGUI.visible: self.player.playerGUI.hide() osd.active = False self.mpvgoom.set_fullscreen() skin.clear() skin.suspend() rc.app(self)
def eventhandler(self, event, menuw=None): """ catch OSD_MESSAGE and display it, return False, maybe someone else is watching for the event. """ if event == OSD_MESSAGE: self.poll_counter = 1 self.message = event.arg if not rc.app() or not skin.get_singleton().force_redraw: skin.redraw() elif hasattr(rc.app(), 'im_self') and hasattr(rc.app().im_self, 'redraw'): rc.app().im_self.redraw() return False
def noview(self): logger.debug('noview()') self.mpvgoom.mode = MpvMode.NOVI if rc.app() != self.player.eventhandler: rc.app(self.player) if self.mpvgoom is not None: self.stop_visual() if not self.player.playerGUI.visible: osd.active = True skin.resume() self.player.playerGUI.show()
def start_visual(self): logger.debug('%s.start_visual() self.view=%r self.succession=%r', self.__class__, self.view, self.player.playerGUI.succession) #if self.player.playerGUI.succession != PlayListSuccession.FIRST: # return self.timer.stop() if self.mpvgoom is not None and self.mpvgoom.running: return if self.view == MpvMode.NOVI: return if rc.app() == self.player.eventhandler: title = self.item.title if hasattr(self.item, 'title') and self.item.title else self.item.name self.mpvgoom = MpvGoom(300, 300, 150, 150, title, self.item.image) if self.mpvgoom is None: raise Exception('Cannot initialise MpvGoom') #if self.view == MpvMode.FULL: self.mpvgoom.set_info(self.item.name, 10) self.title = None self.message = None logger.debug('self.mpvgoom.running=%r -> True', self.mpvgoom.running) self.mpvgoom.running = True self.view_func[self.view]() self.mpvgoom.start() self.mpvgoom.timer.start(1.0 / config.MPLAYERVIS_FPS) if self.view == MpvMode.FULL: skin.suspend()
def doChoice1(self, arg=None, menuw=None): mylistofitems = [] mylistofobjects = some_func_that_returns_you_list() for myobject in mylistofobjects: img_item = ImageItem(myobject, self) mylistofitems += [ img_item ] if (len(mylistofitems) == 0): mylistofitems += [menu.MenuItem(_('No Objects found'), menuw.back_one_menu, 0)] myobjectmenu = menu.Menu(_('My Image Objects'), mylistofitems, reload_func=menuw.back_one_menu ) rc.app(None) menuw.pushmenu(myobjectmenu) menuw.refresh()
def __init__(self, iArg=None, iMenuw=None, iWeather=None): self.arg = iArg self.menuw = iMenuw self.weather = iWeather self.menuw.hide(clear=False) rc.app(self) self.skins = ('day', 'forecast', 'week', 'doplar') self.subtitles = (_('Current Conditions'), _('Today\'s Forecast'), _('Extended Forecast'), _('Radar Map')) self.curSkin = 0 self.title = self.weather.name self.subtitle = self.subtitles[0] # Fire up splashscreen and load the plugins skin.draw('weather', self)
def generate_sub_menu(self, arg=None, menuw=None): """ Generates the genre list menu """ gm = [] if arg.has_key('genre'): if arg['genre'] == '': for genre in self.genres.keys(): gm.append(menu.MenuItem('[%s] (%d)' % (genre, self.genres[genre]), action = self.generate_sub_menu, arg = {'genre':genre})) gm.sort(key = self.genresortkey) gms = menu.Menu( _('Genre'), gm, item_types = 'audio') rc.app(None) menuw.pushmenu(gms) menuw.refresh() return if arg.has_key('audiotype'): if arg['audiotype'] == '': gm = [] for atype in self.audiotypes: gm.append(menu.MenuItem('[%s]' % atype, action = self.generate_sub_menu, arg = {'audiotype':atype} )) gms = menu.Menu( _('Format'), gm, item_types = 'audio') rc.app(None) menuw.pushmenu(gms) menuw.refresh() return if arg.has_key('bitrate'): if arg['bitrate'] == '': gm = [] for br in self.bitrates.keys(): gm.append(menu.MenuItem('[%s] (%d)' % (br, self.bitrates[br]), action = self.generate_sub_menu, arg = {'bitrate':br})) gm.sort(key = self.genresortkey) gms = menu.Menu( _('Bitrate'), gm, item_types = 'audio') rc.app(None) menuw.pushmenu(gms) menuw.refresh() return stationlist = [] for stationk in self.stations.keys(): add = False station = self.stations[stationk] for stfilter in arg.keys(): ##genre if stfilter == 'genre': if station['genres'].has_key(arg[stfilter]): add = True else: if station[stfilter] == arg[stfilter]: add = True if add: stationlist.append(self.__builditem(station)) stationlist.sort(key = self.stationsortkey) stationmenu = menu.Menu( arg, stationlist, item_types = 'audio' ) rc.app(None) menuw.pushmenu(stationmenu) menuw.refresh() return