From f712855a9b25c38a3f23abcdff4b556ad72f8334 Mon Sep 17 00:00:00 2001 From: bjschuma Date: Thu, 4 Jun 2009 15:58:18 +0000 Subject: [PATCH] Pass input args from ocarina to ocarina.py when called git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@17 1daee41c-8060-4895-b1f0-2197c00d777a --- trunk/ocarina | 2 +- trunk/ocarina.py | 44 ++++++++++++++++---------------------------- trunk/operations.py | 20 ++++++++++++++++++-- trunk/song.py | 13 ++++++++----- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/trunk/ocarina b/trunk/ocarina index 0b9262b2..0e1fb77e 100755 --- a/trunk/ocarina +++ b/trunk/ocarina @@ -1,2 +1,2 @@ #!/bin/bash -`which python` ocarina.py +`which python` ocarina.py $? diff --git a/trunk/ocarina.py b/trunk/ocarina.py index eb24320e..791a7d49 100644 --- a/trunk/ocarina.py +++ b/trunk/ocarina.py @@ -70,7 +70,7 @@ class main: 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.ops.next) - self.thisButton = self.makeButton("thisButton",None,"This",self.this) + self.thisButton = self.makeButton("thisButton",None,"This",self.ops.this) self.infoButton = self.makeButton("infoButton",None,"Info",self.ops.info) # Add buttons to window self.inside.pack_start(self.playButton,False,False,0) @@ -128,40 +128,28 @@ class main: # Show running time info - def time(self,unused): - if self.song == None: - return - cur = self.song.curTime() - tot = self.song.info.length - self.commands.printLine(cur.toStr()+" / "+tot.toStr()) + #def time(self,unused): + # if self.song == None: + # return + # cur = self.song.curTime() + # tot = self.song.info.length + # self.commands.printLine(cur.toStr()+" / "+tot.toStr()) - # Show detailed song info - #def info(self,widget,data): -# # Return if no song found + + # Show basic song info + #def this(self,unused): + #def this(self,widget,data): + # # Return if no song found # if self.song == None: # return # # Return if no tags found # if self.song.info.tags == None: # print "Could not find any tags" # return - # for tag in self.song.info.tags.keys(): - # print tag+":",self.song.info.tags[tag] - # print self.song.info.filename - - # Show basic song info - #def this(self,unused): - def this(self,widget,data): - # Return if no song found - if self.song == None: - return - # Return if no tags found - if self.song.info.tags == None: - print "Could not find any tags" - return - fields = ["title","artist","track-number","track-count","album"] - for field in fields: - if (field in self.song.info.tags.keys()) == True: - print field+":",self.song.info.tags[field] + # fields = ["title","artist","track-number","track-count","album"] + # for field in fields: + # if (field in self.song.info.tags.keys()) == True: + # print field+":",self.song.info.tags[field] def scanLib(self,dir): diff --git a/trunk/operations.py b/trunk/operations.py index ed1f4858..7b80c0e7 100644 --- a/trunk/operations.py +++ b/trunk/operations.py @@ -39,13 +39,29 @@ class Operations: # Mark progress on the progress bar def markProgress(self,widget,data): - time = self.song.curTime() + time = (False,None) + while time[0] == False: + time = self.song.curTime() widget.set_fraction(float(self.song.current)/float(self.song.total)) - widget.set_text(time.toStr()+" / "+self.song.info.length.toStr()) + widget.set_text(time[1].toStr()+" / "+self.song.info.length.toStr()) #print float(self.song.current)/float(self.song.total) return True + def this(self,widget,data): + # Return if no song found + if self.song == None: + return + # Return if no tags found + if self.song.info.tags == None: + print "Could not find any tags" + return + fields = ["title","artist","track-number","track-count","album"] + for field in fields: + if (field in self.song.info.tags.keys()) == True: + print field+":",self.song.info.tags[field] + + # Print detailed song info def info(self,widget,data): # Return if no song found diff --git a/trunk/song.py b/trunk/song.py index 59610a09..027fc021 100644 --- a/trunk/song.py +++ b/trunk/song.py @@ -88,8 +88,11 @@ class Song(): # Print out current running time def curTime(self): - length = self.player.query_position(self.time_format,None)[0] - self.current = length - dur = Duration() - dur.setTime(length) - return dur + try: + length = self.player.query_position(self.time_format,None)[0] + self.current = length + dur = Duration() + dur.setTime(length) + return (True,dur) + except: + return (False,None)