view vixm/ @ 30:860c891de6bb master

Remove lots of xmms-related code & get ready to make the whole program a standalone player
author Josef "Jeff" Sipek <>
date Fri, 03 Nov 2006 22:49:09 -0500
parents dfcf1a46fc56
children f97eb9f0c207
line wrap: on
line source

# - playlist interface
# Copyright (C) 2006  Josef "Jeff" Sipek <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

import xmms, re


class playlist:
	def __init__(self, allowrandom=False):
		self.__list = []
		self.__allowrand = allowrandom # allow randomization of this list
	def enqueue(self, song):
		""" Append a song to the list """
	def dequeue(self, song):
		""" Remove a song from the list """
	def pop(self):
		""" Pop the next song """
		return self.__list.pop(0)

	def __getitem__(self, i):
		""" Get item at position i """
		return self.__list[i]

	def __len__(self):
		""" Return the length of the playlist """
		return len(self.__list)

	def search(self, regexp):
		""" Yield all the songs matching regexp """
		for song in self.__list:
			if, str(song), re.IGNORECASE):
				yield song

	def index(self, song):
		""" Returns the index of the first occurence of song """
		return self.__list.index(song)