Mercurial > vixm
changeset 45:2bf81d95246a pure
Move starting code into main.py
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 06 Nov 2006 05:10:37 -0500 |
parents | c46d3f8833f9 |
children | 2d570448aba5 |
files | run vixm/main.py vixm/ui.py |
diffstat | 3 files changed, 47 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/run Mon Nov 06 05:04:44 2006 -0500 +++ b/run Mon Nov 06 05:10:37 2006 -0500 @@ -4,7 +4,7 @@ sys.path.insert(0, "") -from vixm import ui +from vixm import main -ui.run(os.path.join(os.environ['HOME'], ".vixm/list.m3u")) +main.run(os.path.join(os.environ['HOME'], ".vixm/list.m3u"))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vixm/main.py Mon Nov 06 05:10:37 2006 -0500 @@ -0,0 +1,43 @@ +import time + +import playlist, song, player +import ui as uimod + +def run(filename): + """ 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 XMMS's playlist + print "Loading songs from XMMS's playlist..." + songs = [] + idx = 0 + for l in open(filename, "r").readlines(): + if l[0] == "#": + continue + + s = song.song(l[:-1], idx) + lists[playlist.LIST_DEFAULT].enqueue(s) + + idx += 1 + + 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) +
--- a/vixm/ui.py Mon Nov 06 05:04:44 2006 -0500 +++ b/vixm/ui.py Mon Nov 06 05:10:37 2006 -0500 @@ -6,48 +6,10 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -import time, sys, re +import sys, re from threading import Thread -import playlist, song, util, control, player - -def run(filename): - """ 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 XMMS's playlist - print "Loading songs from XMMS's playlist..." - songs = [] - idx = 0 - for l in open(filename, "r").readlines(): - if l[0] == "#": - continue - - s = song.song(l[:-1], idx) - lists[playlist.LIST_DEFAULT].enqueue(s) - - idx += 1 - - print "Instanciating player thread..." - play = player.playerThread() - play.start() - - print "Instanciating ui thread..." - ui = 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) +import playlist, util, control class uiThread(Thread): """ This is the main ui thread class, it does all the magic