Began work on random playback

This commit is contained in:
bjschuma 2010-02-08 10:07:45 -05:00
parent 8b2263b068
commit 75ae830ef2
10 changed files with 48 additions and 166 deletions

View File

@ -139,7 +139,7 @@ def listlib():
write("Current: "+curname)
def getpath(dbid, curtrk):
def getpath(dbid):
curlib = str( settings.get("curlib") )
selr = sql.Select("path","library","id="+curlib)
@ -147,6 +147,4 @@ def getpath(dbid, curtrk):
selt = sql.Select("path","track","id="+str(dbid))
track = selt.execute().fetchone()[0]
# write(root)
# write(track)
write(root+track)
return root+track

View File

@ -63,4 +63,6 @@ def init():
def close():
global pipeline
if not pipeline == None:
pipeline.set_state(gst.STATE_NULL)
pause()
pipeline.set_state(gst.STATE_NULL)
pipeline = None

View File

@ -23,6 +23,8 @@ class Plugin(plugin.Plugin):
write("Usage: music load track")
join = ' '
path = join.join(args)
write("Loading: "+path)
gstreamer.close()
gstreamer.load(path)

View File

@ -11,7 +11,7 @@ from bt import sql
from ct import db
import settings
from manager import run
import manager
class Plugin(plugin.Plugin):
@ -44,16 +44,24 @@ class Plugin(plugin.Plugin):
sel = sql.Select("track","libtrack","library="+str(curlib))
rows = sel.execute().fetchall()
run("next",[rows[nxttrk][0], nxttrk])
manager.run("next",[rows[nxttrk][0], nxttrk])
def run(self, args=None):
# args[0] : database track ID
# args[1] : new current track number
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])
path = db.getpath(args[0])
settings.set("curtrk",args[1])
manager.run("music",["load",path])
manager.run("music",["play"])

View File

@ -1,5 +0,0 @@
__author__="bjschuma"
__date__ ="$Jan 9, 2010 8:07:29 PM$"
__all__ = ["rand"]

View File

@ -1,5 +0,0 @@
__author__="bjschuma"
__date__ ="$Jan 16, 2010 12:46:48 PM$"
__all__ = ["listPage"]

View File

@ -1,46 +0,0 @@
#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Jan 16, 2010 12:47:28 PM$"
import gtk
from guiGTK import *
from bt.message import *
from tools import database
def library():
select = "track.name, artist.name, album.name"
frm = "track,artist,album"
where = "track.artist=artist.id AND track.album=album.id"
return database.select(select,frm,where).fetchall()
class ListPage(box.VBox):
def __init__(self,name):
box.VBox.__init__(self)
self.labelText = name
self.label = label.Label(self.labelText)
self.label.rotate(90)
self.list = list.List(gtk.ListStore(str,str,str), ["Title", "Artist", "Album"])
self.list.rules(True)
self.pack(self.list,True,True)
if name == "Library":
self.fromLibrary()
self.setLabel()
def fromLibrary(self):
for track in library():
self.list.insert(track)
def setLabel(self):
text = self.labelText + " ("
text += str( self.list.count() )
text += ")"
self.label.change(text)

View File

@ -1,59 +0,0 @@
# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Jan 16, 2010 12:18:10 PM$"
global name, app, type, path, opt
name = "test"
app = "scion"
type = "extra"
path = ""
opt = []
from bt.message import write
from manager import manager
import settings
from guiGTK import *
from guiOGTK import *
global window
global vbox
global bar
global tabs
# Called when the plugin needs to perform some action
def run(args):
if args == None:
manager.run("sgtk")
else:
global window, vbox, bar, tabs
window = args[0]
vbox = args[1]
bar = args[2]
window.resize(settings.get("winsize"))
tabs = tabs.Tabs()
vbox.pack(tabs,True,True)
library = listPage.ListPage("Library")
tabs.append(library,library.label)
tabs.tabpos("left")
# Called every time the plugin is enabled
def open():
# Enable scion GTK when we are enabled
manager.run("enable", ["sgtk"])
settings.set("gtkfuncs",run)
settings.set("winsize",(800,600))
# Called every time the plugin is stopped
def close():
pass
def help():
return "Ocarina GTK functions"

View File

@ -1,55 +1,42 @@
# This is a simple test plugin, to make sure everything is working
# Basic plugin class
__author__="bjschuma"
__date__ ="$Jan 2, 2010 1:14:04 PM$"
__date__ ="$Feb 8, 2010 10:00:40 AM$"
global name, app, type, path, opt
name = "rand"
app = "ocarina"
type = "extra"
path = ""
opt = []
from bt import plugin
from bt.message import write
from tools import database
import random
import settings
from bt import signal
def randnext():
cur = str(settings.get("curlib"))
count = database.select("count(*)","libtrack","library="+cur).fetchone()[0]
id = random.randint(0,count)
rows = database.select("track","libtrack","library="+cur).fetchall()
id = rows[id][0]
return id,id
class Plugin(plugin.Plugin):
def __init__(self):
plugin.Plugin.__init__(self)
self.help = ""
# Called every time the plugin is enabled
def open():
settings.init("random",False)
if settings.get("random") == True:
settings.set("next",randnext)
def open(self):
if settings.has("random") == False:
settings.set("random",False)
elif settings.get("random") == True:
signal.register("next",self.randNext,90)
pass
# Called every time the plugin is stopped
def close():
pass
def randNext(self):
pass
def help():
return "Changes next to play a random song"
def run(self, args=None):
if args==None or len(args)==0:
rand = not settings.get("random")
settings.set("random",rand)
if rand == True:
signal.register("next",self.randNext,90)
else:
signal.remove("next",self.randNext)
elif args[0] == "?":
write(settings.get("random"))
# Called when the plugin needs to perform some action
def run(args=None):
if args==None or len(args)==0:
settings.replace("random",not settings.get("random"))
random = settings.get("random")
if random == True:
settings.set("next",next)
else:
settings.pop("next")
elif args[0]=="?":
write(str(settings.get("random")))

View File

@ -1,5 +1,5 @@
#!/bin/bash
CORE=`pwd`/`dirname $0`"/core"
#EXTRA=`pwd`/`dirname $0`"/extra"
cd && `which scion` "-p $CORE" $*
EXTRA=`pwd`/`dirname $0`"/extra"
cd && `which scion` "-p $CORE -p $EXTRA" $*