Can list all librarys, gstreamer.py draws a progress bar on the bottom

of the CLI
This commit is contained in:
bjschuma 2010-01-10 19:29:39 -05:00
parent ad2264440e
commit 2d78ea8fc9
8 changed files with 63 additions and 22 deletions

View File

@ -42,3 +42,4 @@ def run(args=None):
for lib in result:
write(lib[1]+"\t"+lib[2])
return result

View File

@ -36,7 +36,7 @@ def next():
def open():
if settings.has("current") == False:
settings.set("current",0)
settings.set("next",next)
settings.init("next",next)
# Called every time the plugin is stopped
@ -55,7 +55,17 @@ def run(args=None):
database.open()
a = database.select("path","library","id="+curlib).fetchone()[0]
b = database.select("path","track","id="+str(id)).fetchone()[0]
info = database.select("track.name, artist.name, album.name",
"track, album, artist",
"track.id="+str(id)+" and track.artist=artist.id and track.album=album.id").fetchone()
database.close()
settings.set("current",curtrk)
manager.run("load",([a+b]))
write(info[0])
write("By: "+info[1])
write("From: "+info[2])
manager.run("play")

View File

@ -25,7 +25,7 @@ from tools import gstreamer
settings.set("user", join(settings.get("user"),".ocarina2"))
mkdir(settings.get("user"))
manager.restoresession()
#manager.restoresession()
bt.proc.setname("Ocarina2")

View File

@ -4,22 +4,11 @@ __author__="bjschuma"
__date__ ="$Dec 27, 2009 9:58:50 PM$"
global name, app, type, path, opt
name = "database"
app = "ocarina"
type = "core"
path = ""
opt = []
import settings
from bt.file import *
import sqlite3
#global conn, c
#conn = None
#c = None
global db
global conn
global vals

View File

@ -8,9 +8,14 @@ from bt.file import *
import gst
import settings
from manager import manager
from cline import message
global pipeline
pipeline = None
global time
time = gst.Format(gst.FORMAT_TIME)
def load(filename):
@ -18,7 +23,7 @@ def load(filename):
if checkPath(filename) == False:
return
write("loading file: "+filename)
write("loading file: "+filename,True)
bin = gst.element_factory_make("playbin", None)
bin.set_property("uri", "file://"+filename)
bin.set_state(gst.STATE_PAUSED)
@ -39,6 +44,37 @@ def pause():
pipeline.set_state(gst.STATE_PAUSED)
def progress():
global pipeline
global time
# Don't bother to go on if the pipeline isn't playing
if not pipeline.get_state()[1] == gst.STATE_PLAYING:
return -1
position = pipeline.query_position(time)[0]
total = pipeline.query_duration(time)[0]
return float(position) / float(total)
# If the song is done, play the next song
def done():
p = progress()
if p == -1:
return
max = int(settings.get("maxyx")[1] * p)
bar = "="
message.disp(bar*max, settings.get("maxyx")[0]-1)
if p == 1.0:
#if position == total:
manager.run("next")
# Called every time the plugin is enabled
@ -47,6 +83,9 @@ def init():
pipeline = gst.Pipeline()
pipeline.set_state(gst.STATE_NULL)
songs = settings.get("args")
settings.set("everyloop",done)
if len(songs) > 0:
load(songs[0])
settings.replace("args", [])

2
src/extra/__init__.py Normal file
View File

@ -0,0 +1,2 @@
__author__="bjschuma"
__date__ ="$Jan 9, 2010 8:07:29 PM$"

View File

@ -7,7 +7,7 @@ __date__ ="$Jan 2, 2010 1:14:04 PM$"
global name, app, type, path, opt
name = "rand"
app = "ocarina"
type = "core"
type = "extra"
path = ""
opt = []
@ -17,7 +17,7 @@ import random
import settings
def next():
def randnext():
cur = str(settings.get("curlib"))
count = database.select("count(*)","libtrack","library="+cur).fetchone()[0]
id = random.randint(0,count)
@ -28,10 +28,9 @@ def next():
# Called every time the plugin is enabled
def open():
if settings.has("random") == False:
settings.set("random",False)
else:
settings.set("next",next)
settings.init("random",False)
if settings.get("random") == True:
settings.set("next",randnext)
# Called every time the plugin is stopped

View File

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