def cwd(self, arg=None, menuw=None): """ make a menu item for each file in the directory """ logger.log(9, 'cwd(arg=%r, menuw=%r)', arg, menuw) play_items = [] number = len(self.info['tracks']) if hasattr(self.info, 'mixed'): number -= 1 for i in range(0, number): title = self.info['tracks'][i]['title'] item = AudioItem('cdda://%d' % (i + 1), self, title, scan=False) # XXX FIXME: set also all the other info here if AudioInfo # XXX will be based on mmpython #item.set_info('', self.name, title, i+1, self.disc_id[1], '') item.info = self.info['tracks'][i] item.length = item.info['length'] if config.MPLAYER_ARGS.has_key('cd'): item.mplayer_options += (' ' + config.MPLAYER_ARGS['cd']) if self.devicename: item.mplayer_options += ' -cdrom-device %s' % self.devicename play_items.append(item) # add all playable items to the playlist of the directory # to play one files after the other self.playlist = play_items # all items together items = [] # random playlist (only active for audio) if 'audio' in config.DIRECTORY_ADD_RANDOM_PLAYLIST and len( play_items) > 1: pl = Playlist(_('Random Playlist'), play_items, self, random=True) pl.autoplay = True items += [pl] items += play_items if hasattr(self.info, 'mixed'): d = DirItem(self.media.mountdir, self) d.name = _('Data files on disc') items.append(d) self.play_items = play_items title = self.name if title[0] == '[' and title[-1] == ']': title = self.name[1:-1] item_menu = menu.Menu(title, items, item_types=self.display_type) if menuw: menuw.pushmenu(item_menu) return items
def cwd(self, arg=None, menuw=None): """ make a menu item for each file in the directory """ logger.log( 9, 'cwd(arg=%r, menuw=%r)', arg, menuw) play_items = [] number = len(self.info['tracks']) if hasattr(self.info, 'mixed'): number -= 1 for i in range(0, number): title=self.info['tracks'][i]['title'] item = AudioItem('cdda://%d' % (i+1), self, title, scan=False) # XXX FIXME: set also all the other info here if AudioInfo # XXX will be based on mmpython #item.set_info('', self.name, title, i+1, self.disc_id[1], '') item.info = self.info['tracks'][i] item.length = item.info['length'] if config.MPLAYER_ARGS.has_key('cd'): item.mplayer_options += (' ' + config.MPLAYER_ARGS['cd']) if self.devicename: item.mplayer_options += ' -cdrom-device %s' % self.devicename play_items.append(item) # add all playable items to the playlist of the directory # to play one files after the other self.playlist = play_items # all items together items = [] # random playlist (only active for audio) if 'audio' in config.DIRECTORY_ADD_RANDOM_PLAYLIST and len(play_items) > 1: pl = Playlist(_('Random Playlist'), play_items, self, random=True) pl.autoplay = True items += [ pl ] items += play_items if hasattr(self.info, 'mixed'): d = DirItem(self.media.mountdir, self) d.name = _('Data files on disc') items.append(d) self.play_items = play_items title = self.name if title[0] == '[' and title[-1] == ']': title = self.name[1:-1] item_menu = menu.Menu(title, items, item_types = self.display_type) if menuw: menuw.pushmenu(item_menu) return items
def fxdhandler(self, fxd, node): """ parse audio specific stuff from fxd files:: <?xml version="1.0" ?> <freevo> <audio title="Smoothjazz"> <cover-img>foo.jpg</cover-img> <mplayer_options></mplayer_options> <player>xine</player> <playlist/> <reconnect/> <url>http://64.236.34.141:80/stream/1005</url> <station>105.3</station> <info> <genre>JAZZ</genre> <description>A nice description</description> </info> </audio> </freevo> Everything except title and url is optional. If <player> is set, this player will be used (possible xine, mplayer or radioplayer). The tag <playlist/> signals that this url is a playlist (mplayer needs that). <reconnect/> signals that the player should reconnect when the connection stopps. If <player> is radioplayer also the radioplayer (not radio) plugin must be activated. In this case, <station> defines the frequency used as '%s' in RADIO_CMD. """ a = AudioItem('', fxd.getattr(None, 'parent', None), scan=False) a.name = fxd.getattr(node, 'title', a.name) a.image = fxd.childcontent(node, 'cover-img') a.url = fxd.childcontent(node, 'url') a.station = fxd.childcontent(node, 'station') if a.image: a.image = vfs.join(vfs.dirname(fxd.filename), a.image) a.mplayer_options = fxd.childcontent(node, 'mplayer_options') if fxd.get_children(node, 'player'): a.force_player = fxd.childcontent(node, 'player') if fxd.get_children(node, 'playlist'): a.is_playlist = True if fxd.get_children(node, 'reconnect'): a.reconnect = True fxd.parse_info(fxd.get_children(node, 'info', 1), a) fxd.getattr(None, 'items', []).append(a)
def fxdhandler(self, fxd, node): """ parse audio specific stuff from fxd files <?xml version="1.0" ?> <freevo> <audio title="Smoothjazz"> <cover-img>foo.jpg</cover-img> <mplayer_options></mplayer_options> <player>xine</player> <playlist/> <reconnect/> <url>http://64.236.34.141:80/stream/1005</url> <info> <genre>JAZZ</genre> <description>A nice description</description> </info> </audio> </freevo> Everything except title and url is optional. If <player> is set, this player will be used (possible xine or mplayer). The tag <playlist/> signals that this url is a playlist (mplayer needs that). <reconnect/> sihnals that the player should reconnect when the connection stopps. """ a = AudioItem('', fxd.getattr(None, 'parent', None), scan=False) a.name = fxd.getattr(node, 'title', a.name) a.image = fxd.childcontent(node, 'cover-img') a.url = fxd.childcontent(node, 'url') if a.image: a.image = vfs.join(vfs.dirname(fxd.filename), a.image) a.mplayer_options = fxd.childcontent(node, 'mplayer_options') if fxd.get_children(node, 'player'): a.force_player = fxd.childcontent(node, 'player') if fxd.get_children(node, 'playlist'): a.is_playlist = True if fxd.get_children(node, 'reconnect'): a.reconnect = True fxd.parse_info(fxd.get_children(node, 'info', 1), a) fxd.getattr(None, 'items', []).append(a)
def get(self, parent, files): """ return a list of items based on the files """ items = [] for file in util.find_matches(files, config.AUDIO_SUFFIX): a = AudioItem(file, parent) items.append(a) files.remove(file) return items