def __drawn(self, item): if plugin.getbyname('osd'): plugin.getbyname('osd').draw(('osd', None), self.osd) # draw self.osd.update() # start timer if self.duration and self.slideshow and not self.timer: self.timer = kaa.OneShotTimer(self.signalhandler) self.timer.start(self.duration) # stop slideshow at the end if configured try: index = item.parent.play_items.index(item)+1 length = len(item.parent.play_items) if index == length: self.slideshow = config.IMAGEVIEWER_AUTOPLAY # send information event to LCD2 rc.post_event(Event('IMAGE_VIEW_INFO', arg=(index, length, item.name))) except Exception, why: logger.warning('Invalid parent item: %s', why)
def __init__(self): plugin.Plugin.__init__(self) # get config locations and mod times so we can check if we need # to regen xml config files (because they changed) self.mylocalconf = self.findLocalConf() self.myfconfig = os.environ['FREEVO_CONFIG'] self.tvtimecache = os.path.join(config.FREEVO_CACHEDIR, 'tvtimecache') self.mylocalconf_t = os.path.getmtime(self.mylocalconf) self.myfconfig_t = os.path.getmtime(self.myfconfig) self.major = 0 self.minor = 0 self.minorversion = 0 self.getTvtimeVersion() self.xmltv_supported = self.isXmltvSupported() self.optionD_supported = self.isOptionDSupported() #check/create the stationlist.xml and tvtime.xml self.createTVTimeConfig() # create the tvtime object and register it plugin.register(TVTime(), plugin.TV) plugin.getbyname(plugin.TV).optionD_supported = self.optionD_supported plugin.getbyname(plugin.TV).xmltv_supported = self.xmltv_supported
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() command = copy.copy(self.command) if config.XINE_HAS_NO_LIRC: command.append('--no-lirc') if config.OSD_SINGLE_WINDOW: command += ['-W', str(osd.video_window.id), '--no-mouse'] osd.video_window.show() command.append('dvb://' + tuner_channel) logger.debug('Starting cmd=%s', command) rc.add_app(self) self.app = childapp.ChildApp2(command) dialog.enable_overlay_display(AppTextDisplay(self.ShowMessage)) return None
def play(self, item, menuw): logger.log( 9, 'play(item=%r, menuw=%r)', item, menuw) self.item = item self.filename = item.filename self.command = item.command self.mode = item.mode self.menuw = menuw if not os.path.isfile(self.filename): osd.clearscreen() osd.drawstring(_('File "%s" not found!') % self.filename, 30, 280) osd.update() time.sleep(2.0) self.menuw.refresh() return 0 if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() if plugin.is_active('joy'): try: plugin.getbyname('JOY').disable() except Exception, why: logger.warning('getbyname("JOY"): %s', why)
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 Play(self, mode, tuner_channel=None): """ Start play back. """ if not tuner_channel: tuner_channel = self.fc.getChannel() if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() self.disable_buffering_timer.stop() rc.add_app(self) # 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 self.last_channel == tuner_channel: now = time.time() seconds_since_played = now - self.stop_time logger.debug('Same channel, seconds since last playing this channel %d', seconds_since_played) self.backend.set_events_enabled(True) if seconds_since_played > 120.0: # Start at the end of the buffer buffer_info = self.backend.get_buffer_info() self.backend.seekto(buffer_info[2] - 3) self.__change_state(State.PLAYING) else: logger.debug('New channel, tuning to %s', tuner_channel) self.backend.set_events_enabled(True) self.change_channel(tuner_channel) return None
def prepare(self): """ basic prepare function """ try: for c in self.ints_to_prepare: try: value, scale = getattr(self, c) result = int(round(scale * eval_attr(value))) setattr(self, c, result) except: pass if self.visible not in ('', 'yes'): if len(self.visible) > 4 and self.visible[:4] == 'not ': p = plugin.getbyname(self.visible[4:]) else: p = plugin.getbyname(self.visible) if hasattr(p, 'visible'): p = p.visible if len(self.visible) > 4 and self.visible[:4] == 'not ': self.visible = not p else: self.visible = p except (TypeError, AttributeError): pass
def play(self, item, menuw): _debug_('play(item=%r, menuw=%r)' % (item, menuw), 2) self.item = item self.filename = item.filename self.command = item.command self.mode = item.mode self.menuw = menuw if not os.path.isfile(self.filename): osd.clearscreen() osd.drawstring(_('File "%s" not found!') % self.filename, 30, 280) osd.update() time.sleep(2.0) self.menuw.refresh() return 0 if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() if plugin.is_active('joy'): try: plugin.getbyname('JOY').enable(FALSE) except Exception, e: _debug_('getbyname(\'JOY\')', e, DWARNING)
def __init__(self): plugin.Plugin.__init__(self) # get config locations and mod times so we can check if we need # to regen xml config files (because they changed) self.mylocalconf = self.findLocalConf() self.myfconfig = os.environ['FREEVO_CONFIG'] self.tvtimecache = os.path.join(config.FREEVO_CACHEDIR, 'tvtimecache') self.mylocalconf_t = os.path.getmtime(self.mylocalconf) self.myfconfig_t = os.path.getmtime(self.myfconfig) self.major = 0 self.minor = 0 self.minorversion = 0 self.getTvtimeVersion() self.xmltv_supported = self.isXmltvSupported() self.optionD_supported = self.isOptionDSupported() #check/create the stationlist.xml and tvtime.xml self.createTVTimeConfig() # create the tvtime object and register it plugin.register(TVTime(), plugin.TV) plugin.getbyname(plugin.TV).optionD_supported = self.optionD_supported plugin.getbyname(plugin.TV).xmltv_supported = self.xmltv_supported
def prepare(self): """ basic prepare function """ try: for c in self.ints_to_prepare: try: value,scale = getattr(self, c) result = int(round(scale * eval_attr(value))) setattr(self, c, result) except: pass if self.visible not in ('', 'yes'): if len(self.visible) > 4 and self.visible[:4] == 'not ': p = plugin.getbyname(self.visible[4:]) else: p = plugin.getbyname(self.visible) if hasattr(p, 'visible'): p = p.visible if len(self.visible) > 4 and self.visible[:4] == 'not ': self.visible = not p else: self.visible = p except (TypeError, AttributeError): pass
def eval_attr(attr_value): """ Returns attr_value if it is not a string or evaluates it substituting max for 'MAX' or 'max' in the attr_value string. """ global attr_global_dict if attr_global_dict is None: attr_global_dict = {} # Setup idlebar related values p = plugin.getbyname('idlebar') if p: attr_global_dict['idlebar'] = 1 attr_global_dict['idlebar_height'] = 60 else: attr_global_dict['idlebar'] = 0 attr_global_dict['idlebar_height'] = 0 # Setup buttonbar related values p = plugin.getbyname('buttonbar') if p: attr_global_dict['buttonbar'] = 1 attr_global_dict['buttonbar_height'] = config.BUTTONBAR_HEIGHT else: attr_global_dict['buttonbar'] = 0 attr_global_dict['buttonbar_height'] = 0 return eval(attr_value, attr_global_dict)
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() command = copy.copy(self.command) if not config.XINE_HAS_NO_LIRC and '--no-lirc' in command: command.remove('--no-lirc') if config.OSD_SINGLE_WINDOW: command += ['-W', str(osd.video_window.id), '--no-mouse'] osd.video_window.show() command.append('dvb://' + tuner_channel) logger.debug('Starting cmd=%s', command) rc.add_app(self) self.app = childapp.ChildApp2(command) dialog.enable_overlay_display(AppTextDisplay(self.ShowMessage)) return None
def eval_attr(attr_value): """ Returns attr_value if it is not a string or evaluates it substituting max for 'MAX' or 'max' in the attr_value string. """ global attr_global_dict if attr_global_dict is None: attr_global_dict = {} # Setup idlebar related values p = plugin.getbyname('idlebar') if p: attr_global_dict['idlebar'] = 1 attr_global_dict['idlebar_height'] = 60 else: attr_global_dict['idlebar'] = 0 attr_global_dict['idlebar_height'] = 0 # Setup buttonbar related values p = plugin.getbyname('buttonbar') if p: attr_global_dict['buttonbar'] = 1 attr_global_dict['buttonbar_height'] = config.BUTTONBAR_HEIGHT else: attr_global_dict['buttonbar'] = 0 attr_global_dict['buttonbar_height'] = 0 return eval(attr_value, attr_global_dict)
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): _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 stop(self): logger.log( 9, 'stop()') self.app.stop() rc.remove_app(self) rc.resume() if plugin.is_active('joy'): try: plugin.getbyname('JOY').enable() except Exception, why: logger.warning('getbyname("JOY"): %s', why)
def play(self, item, playerGUI): """ play an audioitem with xmms """ logger.debug('%s.play(item=%r, playerGUI=%r)', self.__module__, item, playerGUI) if item.url: filename = item.url else: filename = item.filename self.playerGUI = playerGUI # Do we care if the file streamed over the network? if not os.path.isfile(filename) and filename.find('://') == -1: return _('%s\nnot found!') % filename # need to convert filename for cds to /mnt/cdrom/Track??.cda # the /mnt/cdrom is supposed to be where you mount your cd if filename.startswith('cdda://'): filename = '%s/Track%.2d.cda' % (item.parent.media.mountdir, int(item.url[7:])) if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() self.item = item #reset idle timeout so update thread doesn't kill xmms after I start a song self.idle = 0 if not xmms.is_running(): xmms.enqueue_and_play_launch_if_session_not_started( [(filename)], xmms_prg=config.FXMMS_CMD) time.sleep(0.2) self.hide_windows() # turn off repeat mode if (xmms.is_repeat()): xmms.toggle_repeat() else: xmms.playlist_clear() xmms.enqueue_and_play([(filename)]) # restart OSD update thread if neccessary if (not self.is_alive): thread.start_new_thread(self.__update_thread, ()) 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. if config.OSD_SINGLE_WINDOW: osd.video_window.hide() self.app.stop('quit\n') rc.remove_app(self) 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() dialog.disable_overlay_display()
def disableMixerReset(self): """Prevent other plugins from resetting the mixer. This can be undone with enableMixerReset(). """ mixer = plugin.getbyname("MIXER") mixer._reset_original = mixer.reset mixer.reset = lambda: None
def chanSet(self, chan, isplayer, app=None, app_cmd=None): new_chan = None for pos in range(len(config.TV_CHANNELS)): chan_cfg = config.TV_CHANNELS[pos] if str(chan_cfg[2]) == str(chan): new_chan = chan self.chan_index = pos if not new_chan: print 'Cannot find tuner channel "%s" in the TV channel listing' % chan return vg = self.getVideoGroup(new_chan, isplayer) if vg.tuner_type == 'external': tuner = plugin.getbyname('EXTERNAL_TUNER') if tuner: tuner.setChannel(new_chan) if vg.input_type == 'tuner' and vg.tuner_chan: freq = self.tunerSetFreq(vg.tuner_chan, app, app_cmd) return freq return 0 else: return self.tunerSetFreq(chan, isplayer, app, app_cmd) return 0
def start_tv(mode=None, channel_id=None): tuner_id = get_tunerid(channel_id) p = plugin.getbyname(plugin.TV) if p is None: AlertBox(text=_('Cannot get TV plug-in')).show() return p.Play(mode, tuner_id)
def start_tv(mode=None, channel_id=None): tuner_id = get_tunerid(channel_id) p = plugin.getbyname(plugin.TV) if p is None: dialog.show_alert(_('Cannot get TV plug-in')) return p.Play(mode, tuner_id)
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. if config.OSD_SINGLE_WINDOW: osd.video_window.hide() self.app.stop('quit\n') rc.remove_app(self) 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() dialog.disable_overlay_display()
def start_tv(mode=None, channel_id=None): tuner_id = get_tunerid(channel_id) p = plugin.getbyname(plugin.TV) if p is None: dialog.show_alert(_('Cannot get TV plug-in')) return p.Play(mode, tuner_id)
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 actions(self): """ return a list of possible actions on this item. """ self.possible_player = [] for p in plugin.getbyname(plugin.VIDEO_PLAYER, True): rating = p.rate(self) * 10 if config.VIDEO_PREFERED_PLAYER == p.name: rating += 1 if hasattr(self, 'force_player') and p.name == self.force_player: rating += 100 self.possible_player.append((rating, p)) self.possible_player.sort(lambda l, o: -cmp(l[0], o[0])) self.player = None self.player_rating = 0 if not self.possible_player: return [] self.player_rating, self.player = self.possible_player[0] if self.url.startswith('dvd://') and self.url[-1] == '/': if self.player_rating >= 20: items = [(self.play, _('Play DVD')), (self.dvd_vcd_title_menu, _('DVD title list'))] else: items = [(self.dvd_vcd_title_menu, _('DVD title list')), (self.play, _('Play default track'))] elif self.url == 'vcd://': if self.player_rating >= 20: items = [(self.play, _('Play VCD')), (self.dvd_vcd_title_menu, _('VCD title list'))] else: items = [(self.dvd_vcd_title_menu, _('VCD title list')), (self.play, _('Play default track'))] else: items = [(self.play, _('Play'))] if len(self.possible_player) > 1: items.append( (self.play_alternate, _('Play with alternate player'))) if self.network_play: items.append((self.play_max_cache, _('Play with maximum cache'))) items += configure.get_items(self) if self.variants and len(self.variants) > 1: items = [(self.show_variants, _('Show variants'))] + items if self.mode == 'file' and not self.variants and \ (not self.image or not self.image.endswith('raw')): items.append((self.create_thumbnail, _('Create Thumbnail'), 'create_thumbnail')) return items
def play(self, player=None): logger.debug('%s.play(player=%r)', self.__module__, player) global _player_ if _player_ and _player_.player and _player_.player.is_playing(): _player_.stop() _player_ = self if self.player and self.player.is_playing(): self.stop() if player: self.player = player else: self.possible_players = [] for p in plugin.getbyname(plugin.AUDIO_PLAYER, True): rating = p.rate(self.item) * 10 if config.AUDIO_PREFERED_PLAYER == p.name: rating += 1 if hasattr( self.item, 'force_player') and p.name == self.item.force_player: rating += 100 if (rating, p) not in self.possible_players: self.possible_players += [(rating, p)] self.possible_players = filter(lambda l: l[0] > 0, self.possible_players) self.possible_players.sort(lambda l, o: -cmp(l[0], o[0])) if len(self.possible_players) > 0: self.player_rating, self.player = self.possible_players[0] if self.menuw and self.menuw.visible and self.visible: self.menuw.hide(clear=False) self.running = True error = self.player.play(self.item, self) if error: print error self.running = False if self.visible: rc.remove_app(self.player) self.item.eventhandler(PLAY_END) else: self.paused = False if self.visible and dialog.is_dialog_supported(): self.dialog = audio.show_play_state(dialog.PLAY_STATE_PLAY, self.item, self.get_time_info) self.dialog.show() if self.visible: rc.add_app(self.player) self.refresh()
def play(self, item, playerGUI): """ play an audioitem with xmms """ logger.debug('%s.play(item=%r, playerGUI=%r)', self.__module__, item, playerGUI) if item.url: filename = item.url else: filename = item.filename self.playerGUI = playerGUI # Do we care if the file streamed over the network? if not os.path.isfile(filename) and filename.find('://') == -1: return _('%s\nnot found!') % filename # need to convert filename for cds to /mnt/cdrom/Track??.cda # the /mnt/cdrom is supposed to be where you mount your cd if filename.startswith('cdda://'): filename = '%s/Track%.2d.cda' % (item.parent.media.mountdir, int(item.url[7:])) if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() self.item = item #reset idle timeout so update thread doesn't kill xmms after I start a song self.idle = 0 if not xmms.is_running(): xmms.enqueue_and_play_launch_if_session_not_started([(filename)],xmms_prg=config.FXMMS_CMD) time.sleep(0.2) self.hide_windows() # turn off repeat mode if (xmms.is_repeat()): xmms.toggle_repeat() else: xmms.playlist_clear() xmms.enqueue_and_play([(filename)]) # restart OSD update thread if neccessary if (not self.is_alive): thread.start_new_thread(self.__update_thread, ()) 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.remove_app(self)
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.remove_app(self)
def __init__(self, parent): _debug_('YoutubeVideo.__init__(parent=%r)' % (parent), 2) # look for a default player for p in plugin.getbyname(plugin.VIDEO_PLAYER, True): if config.VIDEO_PREFERED_PLAYER == p.name: self.player = p Item.__init__(self, parent) self.name = _('Youtube videos') self.type = 'youtube'
def prepare(self): """ basic prepare function """ try: if self.visible not in ('', 'yes'): if len(self.visible) > 4 and self.visible[:4] == 'not ': p = plugin.getbyname(self.visible[4:]) else: p = plugin.getbyname(self.visible) if hasattr(p, 'visible'): p = p.visible if len(self.visible) > 4 and self.visible[:4] == 'not ': self.visible = not p else: self.visible = p except (TypeError, AttributeError): pass
def setAudioBalance(self, b): """Set the balance between video channel sound and any sound we might be playing. b=0 gives our PCM channel full volume and the line in nothing, b=1 sets the line in to full volume and PCM is muted. """ mixer = plugin.getbyname("MIXER") mixer.setPcmVolume(int(config.MAX_VOLUME * (1-b) + 0.5)) mixer.setLineinVolume(int(config.MAX_VOLUME * b + 0.5))
class PluginInterface(IdleBarPlugin): """ This plugin shows the current volume level on the idlebar. Activate with: | plugin.activate('idlebar.volume.Volume', level=0) """ def __init__(self): IdleBarPlugin.__init__(self) self.plugin_name = 'idlebar.volume' self.barimg = os.path.join(config.ICON_DIR, 'status/volume_bar.png') self.outimg = os.path.join(config.ICON_DIR, 'status/volume_out.png') self.muteimg = os.path.join(config.ICON_DIR, 'status/volume_mute.png') self.cacheimg = {} self.muted = False self.volume = -1 def getimage(self, image, osd, cache=False): if image.find(config.ICON_DIR) == 0 and image.find( osd.settings.icon_dir) == -1: new_image = os.path.join(osd.settings.icon_dir, image[len(config.ICON_DIR) + 1:]) if os.path.isfile(new_image): image = new_image if cache: if image not in self.cacheimg.keys(): self.cacheimg[image] = pygame.image.load(image) return self.cacheimg[image] return pygame.image.load(image) def draw(self, (type, object), x, osd): mixer = plugin.getbyname('MIXER') w = 0 if mixer: muted = mixer.getMuted() vol = (float(mixer.getVolume()) / float(config.MIXER_VOLUME_MAX)) if muted != self.muted or vol != self.volume: self.muted = muted self.volume = vol if muted: self.muted = muted volout = self.getimage(self.muteimg, osd, True) self.cacheimg['cached'] = volout else: self.volume = vol volbar = self.getimage(self.barimg, osd, True) volout = self.getimage(self.outimg, osd) w, h = volout.get_size() volout.blit(volbar, (0, 0), (0, 0, (w * vol), h)) self.cacheimg['cached'] = volout else: volout = self.getimage('cached', osd, True) w = osd.drawimage(volout, (x, osd.y + 10, -1, -1))[0] return w
def __init__(self, parent): logger.log(9, 'YoutubeVideo.__init__(parent=%r)', parent) # look for a default player for p in plugin.getbyname(plugin.VIDEO_PLAYER, True): if config.VIDEO_PREFERED_PLAYER == p.name: self.player = p Item.__init__(self, parent) self.name = _('Youtube videos') self.type = 'youtube' self.image = config.IMAGE_DIR + '/youtube.png'
def __init__(self, parent): logger.log( 9, 'YoutubeVideo.__init__(parent=%r)', parent) # look for a default player for p in plugin.getbyname(plugin.VIDEO_PLAYER, True): if config.VIDEO_PREFERED_PLAYER == p.name: self.player = p Item.__init__(self, parent) self.name = _('Youtube videos') self.type = 'youtube' self.image = config.IMAGE_DIR + '/youtube.png'
def play(self, item, playerGUI): """ play an audio file with xine """ self.item = item self.playerGUI = playerGUI add_args = [] if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() url = item.url if url.startswith('cdda://'): url = url.replace('//', '/') add_args.append('cfg:/input.cdda_device:%s' % item.media.devicename) command = self.command.split(' ') + add_args + [url] self.app = XineApp(command, self)
def play(self, player=None): logger.debug('%s.play(player=%r)', self.__module__, player) global _player_ if _player_ and _player_.player and _player_.player.is_playing(): _player_.stop() _player_ = self if self.player and self.player.is_playing(): self.stop() if player: self.player = player else: self.possible_players = [] for p in plugin.getbyname(plugin.AUDIO_PLAYER, True): rating = p.rate(self.item) * 10 if config.AUDIO_PREFERED_PLAYER == p.name: rating += 1 if hasattr(self.item, 'force_player') and p.name == self.item.force_player: rating += 100 if (rating, p) not in self.possible_players: self.possible_players += [(rating, p)] self.possible_players = filter(lambda l: l[0] > 0, self.possible_players) self.possible_players.sort(lambda l, o: -cmp(l[0], o[0])) if len(self.possible_players) > 0: self.player_rating, self.player = self.possible_players[0] if self.menuw and self.menuw.visible and self.visible: self.menuw.hide(clear=False) self.running = True error = self.player.play(self.item, self) if error: print error self.running = False if self.visible: rc.remove_app(self.player) self.item.eventhandler(PLAY_END) else: self.paused = False if self.visible and dialog.is_dialog_supported(): self.dialog = audio.show_play_state(dialog.PLAY_STATE_PLAY, self.item, self.get_time_info) self.dialog.show() if self.visible: rc.add_app(self.player) self.refresh()
def eventhandler(self, event, menuw=None): _debug_("Saw %s" % event) if event in (em.MENU_GOTO_MAINMENU, em.MENU_BACK_ONE_MENU): plug = plugin.getbyname('video.mplayer_ppmenu.item') if plug: _debug_('Changing to default post-processing and ratio options') plug.set_default_vfp_options() plug.set_default_vfi_options() plug.set_default_ratio() return False
def show(self, arg=None, menuw=None): _debug_('show(self, arg=None, menuw=None)', 2) gui = audio.player.get() # restore the menuw's gui.menuw = menuw gui.item.menuw = menuw if gui.item.parent: gui.item.parent.menuw = menuw # hide the menu and show the player menuw.hide() gui.show() mpav = plugin.getbyname('audio.mpav') if mpav: mpav.start_mpav() mplvis = plugin.getbyname('audio.mplayervis') if mplvis: mplvis.stop_visual() mplvis.start_visual()
def stop(self): if self.app: if self.viewer=='xine': self.app.stop('quit\n') else: self.app.stop() rc.remove_app(self) self.app=None if self.tcp: # retrieve and store the current channel channel=self.svdrp.current_chan() self.vdrinterface.putVar('CURRENT_TV_CHANNEL',channel) self.vdrinterface.saveVars() if self.vdrhasfreevoplugin: # turn on VDR remotes self.svdrp.write_cmd('plug freevo rctl on' + '\n') self.hitk('stop') self.svdrp.close() self.svdrp=0 if plugin.getbyname('MIXER'): plugin.getbyname('MIXER').reset() self.menuw.show()
def calculatesizes(self, osd, font): """ sizecalcs is not necessery on every pass """ logger.log(8, 'calculatesizes(osd=%r, font=%r)', osd, font) if not hasattr(self, 'idlebar'): self.idlebar = plugin.getbyname('idlebar') if self.idlebar: self.idlebar_max = osd.width + osd.x for p in plugin.get('idlebar'): if hasattr(p, 'clock_left_position'): self.idlebar_max = p.clock_left_position if self.idlebar_max - self.idlebar.free_space < 250: logger.info( 'free space in idlebar to small, using normal detach') self.idlebar = None pad_internal = 5 # internal padding for box vs text if self.calculate: self.calculate = False self.font_h = font.font.height total_width = osd.width + 2 * osd.x total_height = osd.height + 2 * osd.y pad = 10 # padding for safety (overscan may not be 100% correct) bar_height = self.font_h bar_width = 0 for r in self.render: bar_height += self.font_h bar_width = max(bar_width, font.font.stringsize(r)) y = total_height - bar_height - config.OSD_OVERSCAN_BOTTOM - skin.attr_global_dict[ 'buttonbar_height'] x = total_width - bar_width - config.OSD_OVERSCAN_RIGHT self.y = y - osd.y - pad - pad_internal self.x = x - osd.x - pad - pad_internal self.w = bar_width + pad + pad_internal + 10 self.h = 70 self.t_y = self.y + pad_internal self.t_x = self.x + pad_internal self.t_w = bar_width + 5 # in case of shadow if self.idlebar: self.y = osd.y + 5 self.x = self.image and self.idlebar.free_space + 70 or self.idlebar.free_space self.t_y = self.y self.t_x = self.x self.t_w = min(self.t_w, self.idlebar_max - self.x - 30)
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')
def calculatesizes(self, osd, font): """ sizecalcs is not necessery on every pass """ logger.log( 8, 'calculatesizes(osd=%r, font=%r)', osd, font) if not hasattr(self, 'idlebar'): self.idlebar = plugin.getbyname('idlebar') if self.idlebar: self.idlebar_max = osd.width + osd.x for p in plugin.get('idlebar'): if hasattr(p, 'clock_left_position'): self.idlebar_max = p.clock_left_position if self.idlebar_max - self.idlebar.free_space < 250: logger.info('free space in idlebar to small, using normal detach') self.idlebar = None pad_internal = 5 # internal padding for box vs text if self.calculate: self.calculate = False self.font_h = font.font.height total_width = osd.width + 2*osd.x total_height = osd.height + 2*osd.y pad = 10 # padding for safety (overscan may not be 100% correct) bar_height = self.font_h bar_width = 0 for r in self.render: bar_height += self.font_h bar_width = max(bar_width, font.font.stringsize(r)) y = total_height - bar_height - config.OSD_OVERSCAN_BOTTOM - skin.attr_global_dict['buttonbar_height'] x = total_width - bar_width - config.OSD_OVERSCAN_RIGHT self.y = y - osd.y - pad - pad_internal self.x = x - osd.x - pad - pad_internal self.w = bar_width + pad + pad_internal + 10 self.h = 70 self.t_y = self.y + pad_internal self.t_x = self.x + pad_internal self.t_w = bar_width + 5 # in case of shadow if self.idlebar: self.y = osd.y + 5 self.x = self.image and self.idlebar.free_space + 70 or self.idlebar.free_space self.t_y = self.y self.t_x = self.x self.t_w = min(self.t_w, self.idlebar_max - self.x - 30)
def detach(self): _debug_('detach(self)', 2) gui = audio.player.get() # hide the player and show the menu mpav = plugin.getbyname('audio.mpav') if mpav: mpav.stop_mpav() mplvis = plugin.getbyname('audio.mplayervis') if mplvis: mplvis.stop_visual() gui.hide() gui.menuw.show() # set all menuw's to None to prevent the next title to be # visible again gui.menuw = None gui.item.menuw = None if gui.item.parent: gui.item.parent.menuw = None rc.post_event(plugin.event('DETACH'))
def eval_attr(attr_value, max): """ Returns attr_value if it is not a string or evaluates it substituting max for 'MAX' or 'max' in the attr_value string. """ if isinstance(attr_value,types.TupleType): global attr_global_dict if attr_global_dict is None: attr_global_dict = {} # Setup idlebar related values p = plugin.getbyname('idlebar') if p: attr_global_dict['idlebar'] = 1 attr_global_dict['idlebar_height'] = 60 else: attr_global_dict['idlebar'] = 0 attr_global_dict['idlebar_height'] = 0 # Setup buttonbar related values p = plugin.getbyname('buttonbar') if p: attr_global_dict['buttonbar'] = 1 attr_global_dict['buttonbar_height'] = config.BUTTONBAR_HEIGHT else: attr_global_dict['buttonbar'] = 0 attr_global_dict['buttonbar_height'] = 0 attr_str,scale = attr_value # Set max values if max is not None: scaled_max = int(round(float(max) / scale)) attr_global_dict['MAX'] = scaled_max attr_global_dict['max'] = scaled_max return int(round(scale * eval(attr_str, attr_global_dict))) return attr_value
def actions(self, item): """ Perform the action add -aspect to the mplayer command line """ config.MPLAYER_ARGS_DEF = self.args_def for p in plugin.getbyname(plugin.VIDEO_PLAYER, True): if config.VIDEO_PREFERED_PLAYER == p.name: self.player = p if item.type == 'video' and self.player.name == 'mplayer': ratio = item['mplayer_aspect'] if ratio: config.MPLAYER_ARGS_DEF = self.args_def + ' -aspect ' + ratio logger.debug('Setting movie aspect to: %s', ratio) return []
def start_tvguide(self, arg, menuw): # Check that the TV channel list is not None if not config.TV_CHANNELS: msg = _('The list of TV channels is invalid!\n') msg += _('Please check the config file.') dialog.show_alert(msg) return if arg == 'record': start_tv(None, ('record', None)) return guide = plugin.getbyname('tvguide') if guide: guide.start(self.get_start_time(), start_tv, menuw) else: TVGuide(tv.epg.channels, self.get_start_time(), start_tv, menuw)
def actions(self, item): self.player = None for p in plugin.getbyname(plugin.VIDEO_PLAYER, True): if config.VIDEO_PREFERED_PLAYER == p.name: self.player = p if item.type == 'video' and self.player and self.player.name == 'mplayer': self.files = [] self.item = item if not item.files: return [] fs = item.files.get() for f in fs: if f.endswith('.img') or f.endswith('.iso'): self.files.append(f) if len(self.files)>0: return [ ( self.play_dvd , _('Play image as DVD')) ] return []
def play(self, item, playerGUI): """ play a radioitem with radio player """ logger.debug('%s.play(item=%r, playerGUI=%r)', self.__module__, item, playerGUI) self.playerGUI = playerGUI self.item = item #self.item.elapsed = 0 self.starttime = time.time() try: logger.debug('play %r', self.item.station) except AttributeError: return 'Cannot play with RadioPlayer - no station' self.mode = 'play' mixer = plugin.getbyname('MIXER') if mixer: mixer_vol = config.MIXER_VOLUME_RADIO_IN mixer.setLineinVolume(mixer_vol) mixer.setIgainVolume(mixer_vol) mixer.setMicVolume(mixer_vol) logger.debug('RadioPlayer mixer is %s', mixer) if config.RADIO_CMD.find('ivtv-radio') >= 0: # IVTV cards logger.debug('%s -f %s &', config.RADIO_CMD, self.item.station) os.system('%s -f %s &' % (config.RADIO_CMD, self.item.station)) else: # BTTV cards logger.debug('%s', config.RADIO_CMD_START%self.item.station) os.system('%s' % (config.RADIO_CMD_START % self.item.station)) #thread.start_new_thread(self.__update_thread, ()) rc.add_app(self) rc.post_event(PLAY_START) return None
def stop(self): """ Stop mplayer and set thread to idle """ logger.debug('Radio Player Stop') self.mode = 'stop' mixer = plugin.getbyname('MIXER') if mixer: mixer.setLineinVolume(0) mixer.setMicVolume(0) mixer.setIgainVolume(0) # Input on emu10k cards. else: logger.warning('Radio Player failed to find a mixer') if config.RADIO_CMD.find('ivtv-radio') >= 0: # IVTV cards os.system('killall -9 aplay') else: # BTTV cards logger.debug('%s', config.RADIO_CMD_STOP) os.system('%s' % config.RADIO_CMD_STOP) rc.post_event(PLAY_END) rc.remove_app(self)
def enableMixerReset(self): """Allow mixer resets again""" mixer = plugin.getbyname("MIXER") mixer.reset = mixer._reset_original
def __init__(self, xine): """ MixerControl constructor """ self.xine = xine self.mixer = plugin.getbyname('MIXER') self.volume = 0
def Play(self, mode, tuner_channel=None): """ """ logger.log( 9, 'MPlayer.Play(mode=%r, tuner_channel=%r)', mode, tuner_channel) # Try to see if the channel is not tunable try: channel = int(tuner_channel) except ValueError: channel = 0 vg = self.current_vg = self.fc.getVideoGroup(tuner_channel, True) if not tuner_channel: tuner_channel = self.fc.getChannel() # Convert to MPlayer TV setting strings device = 'device=%s' % vg.vdev input = 'input=%s' % vg.input_num norm = 'norm=%s' % vg.tuner_norm w, h = config.TV_VIEW_SIZE outfmt = 'outfmt=%s' % config.TV_VIEW_OUTFMT # Build the MPlayer command line args = { 'nice': config.MPLAYER_NICE, 'cmd': config.MPLAYER_CMD, 'vo': '-vo %s' % config.MPLAYER_VO_DEV, 'vo_opts': config.MPLAYER_VO_DEV_OPTS, 'vc': '', 'ao': '-ao %s' % config.MPLAYER_AO_DEV, 'ao_opts': config.MPLAYER_AO_DEV_OPTS, 'default_args': config.MPLAYER_ARGS_DEF.split(), 'mode_args': config.MPLAYER_ARGS.has_key(mode) and config.MPLAYER_ARGS[mode].split() or [], 'geometry': (config.CONF.x or config.CONF.y) and '-geometry %d:%d' % (config.CONF.x, config.CONF.y) or '', 'verbose': '', 'dvd-device': '', 'cdrom-device': '', 'alang': '', 'aid': '', 'slang': '', 'sid': '', 'playlist': '', 'field-dominance': '', 'edl': '', 'mc': '', 'delay': '', 'sub': '', 'audiofile': '', 'af': [], 'vf': [], 'tv': '', 'url': '', 'disable_osd': False, } if dialog.overlay_display_supports_dialogs: # Disable the mplayer OSD if we have a better option. args['disable_osd'] = True if mode == 'tv': if vg.group_type == 'ivtv': ivtv_dev = ivtv.IVTV(vg.vdev) ivtv_dev.init_settings() ivtv_dev.setinputbyname(vg.input_type) cur_std = ivtv_dev.getstd() import tv.v4l2 try: new_std = tv.v4l2.NORMS.get(vg.tuner_norm) if cur_std != new_std: ivtv_dev.setstd(new_std) except: logger.error('Error! Videogroup norm value "%s" not from NORMS: %s', vg.tuner_norm, tv.v4l2.NORMS.keys()) ivtv_dev.close() # Do not set the channel if negative if channel >= 0: self.fc.chanSet(tuner_channel, True) args['url'] = vg.vdev if config.MPLAYER_ARGS.has_key('ivtv'): args['mode_args'] = config.MPLAYER_ARGS['ivtv'].split() elif vg.group_type == 'webcam': self.fc.chanSet(tuner_channel, True, app='mplayer') args['url'] = '' if config.MPLAYER_ARGS.has_key('webcam'): args['mode_args'] = config.MPLAYER_ARGS['webcam'].split() elif vg.group_type == 'dvb': self.fc.chanSet(tuner_channel, True, app='mplayer') args['url'] = ('dvb://%s' % (tuner_channel,)) args['mode_args'] = config.MPLAYER_ARGS['dvb'].split() elif vg.group_type == 'tvalsa': freq_khz = self.fc.chanSet(tuner_channel, True, app='mplayer') tuner_freq = '%1.3f' % (freq_khz / 1000.0) args['tv'] = '-tv driver=%s:%s:freq=%s:%s:%s:%s:width=%s:height=%s:%s %s' % \ (config.TV_DRIVER, vg.adev, tuner_freq, device, input, norm, w, h, outfmt, config.TV_OPTS) args['url'] = 'tv://' if config.MPLAYER_ARGS.has_key('tv'): args['mode_args'] = config.MPLAYER_ARGS['tv'].split() else: # group_type == 'normal' freq_khz = self.fc.chanSet(tuner_channel, True, app='mplayer') tuner_freq = '%1.3f' % (freq_khz / 1000.0) args['tv'] = '-tv driver=%s:freq=%s:%s:%s:%s:width=%s:height=%s:%s %s' % \ (config.TV_DRIVER, tuner_freq, device, input, norm, w, h, outfmt, config.TV_OPTS) args['url'] = 'tv://' if config.MPLAYER_ARGS.has_key('tv'): args['mode_args'] = config.MPLAYER_ARGS['tv'].split() elif mode == 'vcr': args['tv'] = '-tv driver=%s:%s:%s:%s:width=%s:height=%s:%s %s' % \ (config.TV_DRIVER, device, input, norm, w, h, outfmt, config.TV_OPTS) args['url'] = 'tv://' if config.MPLAYER_ARGS.has_key('tv'): args['mode_args'] = config.MPLAYER_ARGS['tv'].split() else: logger.error('Mode "%s" is not implemented', mode) return logger.debug('mplayer args = %r', args) vo = ['%(vo)s' % args, '%(vo_opts)s' % args] vo = filter(len, vo) vo = ':'.join(vo) ao = ['%(ao)s' % args, '%(ao_opts)s' % args] ao = filter(len, ao) ao = ':'.join(ao) command = ['--prio=%(nice)s' % args] command += ['%(cmd)s' % args] command += ['-slave'] command += str('%(verbose)s' % args).split() command += str('%(geometry)s' % args).split() command += vo.split() command += str('%(vc)s' % args).split() command += ao.split() command += args['default_args'] command += args['mode_args'] command += str('%(dvd-device)s' % args).split() command += str('%(cdrom-device)s' % args).split() command += str('%(alang)s' % args).split() command += str('%(aid)s' % args).split() command += str('%(audiofile)s' % args).split() command += str('%(slang)s' % args).split() command += str('%(sid)s' % args).split() command += str('%(sub)s' % args).split() command += str('%(field-dominance)s' % args).split() command += str('%(edl)s' % args).split() command += str('%(mc)s' % args).split() command += str('%(delay)s' % args).split() if args['af']: command += ['-af', '%s' % ','.join(args['af'])] if args['vf']: command += ['-vf', '%s' % ','.join(args['vf'])] command += str('%(tv)s' % args).split() command += args['disable_osd'] and ['-osdlevel', '0'] or [] if config.OSD_SINGLE_WINDOW: command += ['-wid', str(osd.video_window.id)] osd.video_window.show() # use software scaler? if '-nosws' in command: command.remove('-nosws') elif '-framedrop' not in command: command += config.MPLAYER_SOFTWARE_SCALER.split() #if options: # command += options command = filter(len, command) #command = self.sort_filter(command) url = '%(url)s' % args command += [url] logger.debug('%r', command) self.mode = mode # XXX Mixer manipulation code. # TV is on line in # VCR is mic in # btaudio (different dsp device) will be added later mixer = plugin.getbyname('MIXER') if mixer and config.MIXER_MAJOR_CTRL == 'VOL': mixer_vol = mixer.getMainVolume() mixer.setMainVolume(0) elif mixer and config.MIXER_MAJOR_CTRL == 'PCM': mixer_vol = mixer.getPcmVolume() mixer.setPcmVolume(0) # Start up the TV task self.app = childapp.ChildApp2(command) rc.add_app(self) # Suppress annoying audio clicks time.sleep(0.4) # XXX Hm.. This is hardcoded and very unflexible. if mixer and mode == 'vcr': mixer.setMicVolume(config.MIXER_VOLUME_VCR_IN) elif mixer: mixer.setLineinVolume(config.MIXER_VOLUME_TV_IN) mixer.setIgainVolume(config.MIXER_VOLUME_TV_IN) if mixer and config.MIXER_MAJOR_CTRL == 'VOL': mixer.setMainVolume(mixer_vol) elif mixer and config.MIXER_MAJOR_CTRL == 'PCM': mixer.setPcmVolume(mixer_vol) dialog.enable_overlay_display(AppTextDisplay(self.show_message)) logger.debug('%s: started %s app', time.time(), self.mode)
def update(self): logger.log( 9, 'update()') bar = plugin.getbyname('idlebar') if bar: bar.poll()
def update(self): bar = plugin.getbyname('idlebar') if bar: bar.poll()