Began work on advancing to the next track

This commit is contained in:
bjschuma 2010-02-08 00:09:57 -05:00
parent 9585b3e881
commit 8b2263b068
3 changed files with 67 additions and 11 deletions

View File

@ -12,6 +12,7 @@ from sqlite3 import *
from bt import sql from bt import sql
import settings import settings
def init(): def init():
if sql.dbexists() == True: if sql.dbexists() == True:
return return
@ -115,19 +116,37 @@ def libid(libname):
return result[0] return result[0]
def countlib(libid):
lib = str( libid )
sel = sql.Select("count(*)","libtrack","library="+lib)
count = sel.execute().fetchone()[0]
return count
def listlib(): def listlib():
sel = sql.Select("*","library") sel = sql.Select("*","library")
result = sel.execute().fetchall() result = sel.execute().fetchall()
id = settings.get("curlib") id = settings.get("curlib")
curname = "" curname = ""
write("Id Name Path") write("Id Name Count Path")
write("------------------") write("---------------------------")
for row in result: for row in result:
if row[0] == id: if row[0] == id:
curname = row[1] curname = row[1]
count = str( countlib(row[0]) )
write( str(row[0]) + " " + write( str(row[0]) + " " +
row[1] + " " + row[2] ) row[1] + " " + count + " " + row[2] )
write("Current: "+curname)
#if not curname == "":
#write("") def getpath(dbid, curtrk):
write("Current: "+curname) curlib = str( settings.get("curlib") )
selr = sql.Select("path","library","id="+curlib)
root = selr.execute().fetchone()[0]
selt = sql.Select("path","track","id="+str(dbid))
track = selt.execute().fetchone()[0]
# write(root)
# write(track)
write(root+track)

View File

@ -8,6 +8,8 @@ from bt import plugin
from bt.message import write from bt.message import write
from bt import signal from bt import signal
from ct import gstreamer
class Plugin(plugin.Plugin): class Plugin(plugin.Plugin):
def __init__(self): def __init__(self):
@ -19,7 +21,9 @@ class Plugin(plugin.Plugin):
def loadTrack(self,args): def loadTrack(self,args):
if len(args) == 0: if len(args) == 0:
write("Usage: music load track") write("Usage: music load track")
return join = ' '
path = join.join(args)
gstreamer.load(path)

View File

@ -5,22 +5,55 @@ __date__ ="$Feb 7, 2010 7:40:01 PM$"
from bt import plugin from bt import plugin
from bt import signal
from bt.message import write
from bt import sql
from ct import db
import settings
from manager import run
class Plugin(plugin.Plugin): class Plugin(plugin.Plugin):
def __init__(self): def __init__(self):
plugin.Plugin.__init__(self) plugin.Plugin.__init__(self)
self.help = "next" self.help = "Advance to the next track"
self.usage = "next [, songID]"
def open(self): def open(self):
pass if settings.has("curtrk") == False:
settings.set("curtrk",-1)
signal.register("next",self.next)
def close(self): def close(self):
pass pass
def run(self, args=None): def next(self):
pass signal.stop("next")
curlib = str(settings.get("curlib"))
count = db.countlib(curlib)
nxttrk = settings.get("curtrk")
if nxttrk > count:
nxttrk = 0
else:
nxttrk += 1
sel = sql.Select("track","libtrack","library="+str(curlib))
rows = sel.execute().fetchall()
run("next",[rows[nxttrk][0], nxttrk])
def run(self, args=None):
if args==None or len(args)==0:
signal.emit("next")
return
elif len(args) == 1:
write("Usage:" + self.usage)
# db ID, list index
path = db.getpath(args[0],args[1])