Hello, I'm trying to code a little plugin for playing directories recursively but i'm very confused about how the playlist do work. My code is attached to the message.
I simply iterate over the shuffled directories and call to Playlist.play() in each directory, but the loop doesn't stop while the playlist is playing and I get all the playlist playing at the same time. Maybe is there a better way of doing this or is a way to stop execution of the loop until the playlist finishes playing the files. Thank you for your help. --
# -*- coding: iso-8859-1 -*- # ----------------------------------------------------------------------- # shuffle_dirs.py - Play folders random and recursively # ----------------------------------------------------------------------- # $Id: shuffle_dirs.py,v 1.6 2004/07/10 12:33:40 dischi Exp $ # # Notes: This is a plugin to play folders random and recursively # # Activate: # plugin.activate('shuffle_dirs') # # ----------------------------------------------------------------------- # $Log: shuffle_dirs.py,v $ # ----------------------------------------------------------------------- # 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 os import random import time import plugin import config import rc from event import * import menu import childapp # Handle child applications import directory class PluginInterface(plugin.ItemPlugin): """ This plugin plays folders random and recursively plugin.activate('shuffle_dirs') """ def __init__(self): plugin.ItemPlugin.__init__(self) self.item = None def shuffle(self, arg=None, menuw=None): _debug_('Initial directory: %s\n' % self.item.dir) init_dir = directory.DirItem(self.item.dir, None, display_type=None, create_metainfo=False) init_dir.play(menuw=menuw) for root, dirs, files in os.walk(self.item.dir): random.shuffle(dirs) for name in dirs: abspath = os.path.join(root, name) _debug_('Now entering: %s\n' % abspath) dir = directory.DirItem(abspath, init_dir, display_type=None, create_metainfo=False) dir.play(menuw=menuw) def actions(self, item): self.item = item myactions = [] if item.type == 'dir' or item.mode == 'dvd': myactions.append((self.shuffle, _('Shuffle directories'))) return myactions else: return []
signature.asc
Description: Digital signature