Fixed finding duration
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@6 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
068de4a7ee
commit
7e0bb34e8d
|
@ -94,6 +94,7 @@ class Library():
|
||||||
indices = set(self.data.map[words[0]])
|
indices = set(self.data.map[words[0]])
|
||||||
for word in words[1:]:
|
for word in words[1:]:
|
||||||
indices = indices & set(self.data.map[word])
|
indices = indices & set(self.data.map[word])
|
||||||
if len(indices) == 1:
|
# Return first instance
|
||||||
return indices.pop()
|
if len(indices) > 0:
|
||||||
|
return indices.pop()
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -23,18 +23,18 @@ class main:
|
||||||
self.song = None
|
self.song = None
|
||||||
# If we were given a song as input, check that it exists and begin playback
|
# If we were given a song as input, check that it exists and begin playback
|
||||||
if len(argv) > 0:
|
if len(argv) > 0:
|
||||||
file = os.path.expanduser(argv[0])
|
split = argv[0].split(self.library.data.path)
|
||||||
if os.path.exists(file) == True:
|
if len(split) > 0:
|
||||||
split = file.split(self.library.data.path)
|
index = self.library.has(split[len(split)-1])
|
||||||
file = split[len(split)-1]
|
info = None
|
||||||
index = self.library.has(file)
|
if index != -1:
|
||||||
info = None
|
info = self.library.data.files[index]
|
||||||
if index != -1:
|
else:
|
||||||
info = self.library.data.files[index]
|
file = os.path.expanduser(argv[0])
|
||||||
else:
|
if os.path.exists(file):
|
||||||
info = SongInfo()
|
info = SongInfo()
|
||||||
info.filename = file
|
info.filename = file
|
||||||
#se
|
if info != None:
|
||||||
self.song = Song(info,self.quit,self.commands.printLines)
|
self.song = Song(info,self.quit,self.commands.printLines)
|
||||||
self.song.play()
|
self.song.play()
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class main:
|
||||||
if self.song == None:
|
if self.song == None:
|
||||||
return
|
return
|
||||||
cur = self.song.curTime()
|
cur = self.song.curTime()
|
||||||
tot = self.song.length
|
tot = self.song.info.length
|
||||||
self.commands.printLine(cur.toStr()+" / "+tot.toStr())
|
self.commands.printLine(cur.toStr()+" / "+tot.toStr())
|
||||||
|
|
||||||
# Show detailed song info
|
# Show detailed song info
|
||||||
|
|
|
@ -56,9 +56,9 @@ class Song():
|
||||||
def play(self):
|
def play(self):
|
||||||
self.player.set_state(gst.STATE_PLAYING)
|
self.player.set_state(gst.STATE_PLAYING)
|
||||||
# Start main loop and find duration (if this hasn't been done yet)
|
# Start main loop and find duration (if this hasn't been done yet)
|
||||||
#if self.info.length == None:
|
if self.info.length == None:
|
||||||
# time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
# self.duration()
|
self.duration()
|
||||||
|
|
||||||
|
|
||||||
# Change state to "paused"
|
# Change state to "paused"
|
||||||
|
|
Loading…
Reference in New Issue