view vixm/main.py @ 48:3eee483b5c4e pure

start with random song if we're supposed to randomize
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Mon, 06 Nov 2006 05:32:34 -0500
parents 1ae315a49009
children
line wrap: on
line source

import time

import playlist, song, player
import ui as uimod

def run(listfn, statsfn):
	""" this is where we start execution """

	# first, let's create the two playlists
	print "Creating playlists..."
	lists = {}
	lists[playlist.LIST_PRIO]	= playlist.playlist()
	lists[playlist.LIST_DEFAULT]	= playlist.playlist(allowrandom=True)

	# read in the info for all the songs in the playlist
	print "Loading songs from the playlist..."
	songs = []
	idx = 0
	for l in open(listfn, "r").readlines():
		if l[0] == "#":
			continue

		s = song.song(l[:-1], idx)
		lists[playlist.LIST_DEFAULT].enqueue(s)

		idx += 1

	lists[playlist.LIST_DEFAULT].first_song()
	
	print "Instanciating player thread..."
	play = player.playerThread()
	play.start()

	print "Instanciating ui thread..."
	ui = uimod.uiThread(play, lists)
	ui.start()

	while not play.shutdown:
		# check which song we are playing now
		if not play.playing:
			play.play_next(lists)

		# sleep
		time.sleep(0.5)