Made script to launch ocarina, moved more functions from main.py to operations.py
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@13 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
378a2a7185
commit
57be9b2599
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
`which python` ocarina.py
|
|
@ -26,8 +26,10 @@ class main:
|
|||
self.library = Library()
|
||||
self.plist = Playlist()
|
||||
self.plist.insert(self.library.nonBanned())
|
||||
self.ops.plist = self.plist
|
||||
self.ops.library = self.library
|
||||
|
||||
self.song = None
|
||||
song = None
|
||||
# If we were given a song as input, check that it exists and begin playback
|
||||
if len(argv) > 0:
|
||||
split = argv[0].split(self.library.data.path)
|
||||
|
@ -41,9 +43,9 @@ class main:
|
|||
if os.path.exists(file):
|
||||
info = SongInfo()
|
||||
info.filename = file
|
||||
self.song = Song(info,self.next)#,self.commands.printLines)
|
||||
self.next("","")
|
||||
self.ops.song = self.song
|
||||
song = Song(info,self.next)#,self.commands.printLines)
|
||||
self.ops.song = song
|
||||
self.ops.next("","")
|
||||
|
||||
#gobject.idle_add(self.markProgress,self.pbar,"progress")
|
||||
|
||||
|
@ -67,7 +69,7 @@ class main:
|
|||
# Make buttons
|
||||
self.playButton = self.makeButton("playButton","images/play.png",None,self.ops.play)
|
||||
self.pauseButton = self.makeButton("pauseButton","images/pause.png",None,self.ops.pause)
|
||||
self.nextButton = self.makeButton("nextButton","images/next.png",None,self.next)
|
||||
self.nextButton = self.makeButton("nextButton","images/next.png",None,self.ops.next)
|
||||
self.thisButton = self.makeButton("thisButton",None,"This",self.this)
|
||||
self.infoButton = self.makeButton("infoButton",None,"Info",self.info)
|
||||
# Add buttons to window
|
||||
|
@ -83,7 +85,7 @@ class main:
|
|||
self.pbar.set_fraction(0)
|
||||
self.pbar.show()
|
||||
# Update the progress bar every 100 ms
|
||||
gobject.timeout_add(100,self.markProgress,self.pbar,"progress")
|
||||
gobject.timeout_add(100,self.ops.markProgress,self.pbar,"progress")
|
||||
self.control.pack_start(self.pbar,False,False,0)
|
||||
|
||||
# Tray
|
||||
|
@ -125,18 +127,6 @@ class main:
|
|||
return button
|
||||
|
||||
|
||||
# Begin playback
|
||||
#def play(self,widget,data):
|
||||
# if self.song == None:
|
||||
# return
|
||||
# self.song.play()
|
||||
|
||||
# Pause music
|
||||
#def pause(self,widget,data):
|
||||
# if self.song == None:
|
||||
# return
|
||||
# self.song.pause()
|
||||
|
||||
# Show running time info
|
||||
def time(self,unused):
|
||||
if self.song == None:
|
||||
|
@ -181,27 +171,8 @@ class main:
|
|||
self.library.scan(dir)
|
||||
|
||||
|
||||
def next(self,widget,data):
|
||||
if self.song != None:
|
||||
self.song.close()
|
||||
index = self.plist.next()
|
||||
if index > -1:
|
||||
self.song = None
|
||||
info = self.library.data.files[index]
|
||||
self.song = Song(info,self.next)#self.commands.printLines)
|
||||
if index > -2:
|
||||
self.song.play()
|
||||
self.ops.song = self.song
|
||||
|
||||
|
||||
def random(self,unused):
|
||||
self.plist.random = not self.plist.random
|
||||
|
||||
|
||||
def markProgress(self,widget,data):
|
||||
self.song.curTime()
|
||||
self.pbar.set_fraction(float(self.song.current)/float(self.song.total))
|
||||
#print float(self.song.current)/float(self.song.total)
|
||||
return True
|
||||
|
||||
if __name__=='__main__':main(sys.argv[1:])
|
||||
|
|
|
@ -4,6 +4,8 @@ from song import Song
|
|||
class Operations:
|
||||
def __init__(self):
|
||||
self.song = None
|
||||
self.plist = None
|
||||
self.library = None
|
||||
|
||||
|
||||
# Begin playback
|
||||
|
@ -18,3 +20,26 @@ class Operations:
|
|||
if self.song == None:
|
||||
return
|
||||
self.song.pause()
|
||||
|
||||
|
||||
# Advance to the next song
|
||||
def next(self,widget,data):
|
||||
# Close open songs
|
||||
if self.song != None:
|
||||
self.song.close()
|
||||
# Get next song
|
||||
index = self.plist.next()
|
||||
if index > -1:
|
||||
self.song = None
|
||||
info = self.library.data.files[index]
|
||||
self.song = Song(info,self.next)
|
||||
if index > -2:
|
||||
self.song.play()
|
||||
|
||||
|
||||
# Mark progress on the progress bar
|
||||
def markProgress(self,widget,data):
|
||||
self.song.curTime()
|
||||
widget.set_fraction(float(self.song.current)/float(self.song.total))
|
||||
#print float(self.song.current)/float(self.song.total)
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue