Added gstreamer. I can now play music again!
This commit is contained in:
parent
22f9d8108f
commit
854b55feaa
|
@ -52,16 +52,42 @@ def newlib(name,path):
|
||||||
try:
|
try:
|
||||||
ins = sql.Insert('library',[None,name,path])
|
ins = sql.Insert('library',[None,name,path])
|
||||||
ins.execute()
|
ins.execute()
|
||||||
|
|
||||||
|
#sel = sql.Insert('library')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def rmtrk(trid):
|
||||||
|
# Get the artist and album of the track
|
||||||
|
sel = sql.Select("artist,album","track","id="+str(trid))
|
||||||
|
(arid,alid) = sel.execute().fetchone()
|
||||||
|
|
||||||
|
rm = sql.Remove("track","id="+str(trid))
|
||||||
|
rm.execute()
|
||||||
|
|
||||||
|
# Remove artist if no other tracks are using this artist
|
||||||
|
sel = sql.Select("count(*)","track","artist="+str(arid))
|
||||||
|
count = sel.execute().fetchone()[0]
|
||||||
|
if count == 0:
|
||||||
|
rm = sql.Remove("artist","id="+str(arid))
|
||||||
|
rm.execute()
|
||||||
|
|
||||||
|
# Remove album if no other tracks are using this album
|
||||||
|
sel = sql.Select("count(*)","track","album="+str(alid))
|
||||||
|
count = sel.execute().fetchone()[0]
|
||||||
|
if count == 0:
|
||||||
|
rm = sql.Remove("album","id="+str(alid))
|
||||||
|
rm.execute()
|
||||||
|
|
||||||
|
|
||||||
def rmlib(name):
|
def rmlib(name):
|
||||||
sel = sql.Select("id","library","name='"+name+"'")
|
sel = sql.Select("id,name","library","name='"+name+"'")
|
||||||
result = sel.execute().fetchall()
|
result = sel.execute().fetchone()
|
||||||
if result == []:
|
if result == []:
|
||||||
return
|
return
|
||||||
libid = result[0][0]
|
libid = result[0]
|
||||||
|
name = result[1]
|
||||||
|
|
||||||
sel = sql.Select("track","libtrack","library="+str(libid))
|
sel = sql.Select("track","libtrack","library="+str(libid))
|
||||||
result = sel.execute().fetchall()
|
result = sel.execute().fetchall()
|
||||||
|
@ -72,13 +98,14 @@ def rmlib(name):
|
||||||
r = sel.execute().fetchall()
|
r = sel.execute().fetchall()
|
||||||
# If track is not in any other library, it can be removed
|
# If track is not in any other library, it can be removed
|
||||||
if r == []:
|
if r == []:
|
||||||
write(r)
|
rmtrk(track[0])
|
||||||
|
|
||||||
|
rm = sql.Remove("library","name='"+name+"'")
|
||||||
|
rm.execute()
|
||||||
|
|
||||||
|
rm = sql.Remove("libtrack","library="+str(libid))
|
||||||
#rm = sql.Remove("library","name='"+name+"'")
|
rm.execute()
|
||||||
#rm.execute()
|
write("Removed library: "+name)
|
||||||
#write("Removed library: "+str(libid))
|
|
||||||
|
|
||||||
|
|
||||||
def listlib():
|
def listlib():
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
#! /usr/bin/python
|
||||||
|
|
||||||
|
# To change this template, choose Tools | Templates
|
||||||
|
# and open the template in the editor.
|
||||||
|
|
||||||
|
__author__="bjschuma"
|
||||||
|
__date__ ="$Feb 5, 2010 7:53:19 PM$"
|
||||||
|
|
||||||
|
|
||||||
|
import gst
|
||||||
|
import settings
|
||||||
|
|
||||||
|
from bt.file import *
|
||||||
|
from bt import signal
|
||||||
|
from bt.message import write
|
||||||
|
|
||||||
|
global pipeline
|
||||||
|
global time
|
||||||
|
pipeline = None
|
||||||
|
time = gst.Format(gst.FORMAT_TIME)
|
||||||
|
|
||||||
|
|
||||||
|
def load(path):
|
||||||
|
path = expandPath(path)
|
||||||
|
if checkPath(path) == False:
|
||||||
|
return
|
||||||
|
|
||||||
|
write("loading file: "+path, True)
|
||||||
|
bin = gst.element_factory_make("playbin",None)
|
||||||
|
bin.set_property("uri", "file://"+path)
|
||||||
|
bin.set_state(gst.STATE_PAUSED)
|
||||||
|
|
||||||
|
global pipeline
|
||||||
|
pipeline = gst.Pipeline("player")
|
||||||
|
pipeline.add(bin)
|
||||||
|
|
||||||
|
|
||||||
|
def play():
|
||||||
|
global pipeline
|
||||||
|
if not pipeline == None:
|
||||||
|
pipeline.set_state(gst.STATE_PLAYING)
|
||||||
|
|
||||||
|
|
||||||
|
def pause():
|
||||||
|
global pipeline
|
||||||
|
if not pipeline == None:
|
||||||
|
pipeline.set_state(gst.STATE_PAUSED)
|
||||||
|
|
||||||
|
|
||||||
|
def init():
|
||||||
|
# Register signals
|
||||||
|
signal.register("play",play)
|
||||||
|
signal.register("pause",pause)
|
||||||
|
|
||||||
|
if settings.has("args") == True:
|
||||||
|
input = settings.get("args")
|
||||||
|
if not input == []:
|
||||||
|
join = ' '
|
||||||
|
path = join.join(input)
|
||||||
|
load(path)
|
||||||
|
|
||||||
|
|
||||||
|
def close():
|
||||||
|
global pipeline
|
||||||
|
if not pipeline == None:
|
||||||
|
pipeline.set_state(gst.STATE_NULL)
|
|
@ -9,6 +9,7 @@ from bt.file import expandPath
|
||||||
from bt.message import write
|
from bt.message import write
|
||||||
from ct import db
|
from ct import db
|
||||||
from ct import update
|
from ct import update
|
||||||
|
import settings
|
||||||
|
|
||||||
|
|
||||||
class Plugin(plugin.Plugin):
|
class Plugin(plugin.Plugin):
|
||||||
|
@ -18,6 +19,10 @@ class Plugin(plugin.Plugin):
|
||||||
self.usage = "library [create, list, prcnt, remove, update]"
|
self.usage = "library [create, list, prcnt, remove, update]"
|
||||||
|
|
||||||
|
|
||||||
|
def open(self):
|
||||||
|
settings.set("curlib",-1)
|
||||||
|
|
||||||
|
|
||||||
def create(self,args):
|
def create(self,args):
|
||||||
usage = "Usage: library create name path"
|
usage = "Usage: library create name path"
|
||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
|
@ -28,6 +33,8 @@ class Plugin(plugin.Plugin):
|
||||||
join = ' '
|
join = ' '
|
||||||
path = expandPath(join.join(args[1:]))
|
path = expandPath(join.join(args[1:]))
|
||||||
db.newlib(name,path)
|
db.newlib(name,path)
|
||||||
|
if settings.get("curlib")==-1:
|
||||||
|
settings.set("curlib")
|
||||||
|
|
||||||
|
|
||||||
def remove(self,args):
|
def remove(self,args):
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Basic plugin class
|
||||||
|
|
||||||
|
__author__="bjschuma"
|
||||||
|
__date__ ="$Feb 5, 2010 7:47:18 PM$"
|
||||||
|
|
||||||
|
|
||||||
|
from bt import plugin
|
||||||
|
from bt.message import write
|
||||||
|
from bt import signal
|
||||||
|
|
||||||
|
|
||||||
|
class Plugin(plugin.Plugin):
|
||||||
|
def __init__(self):
|
||||||
|
plugin.Plugin.__init__(self)
|
||||||
|
self.help = "Used to control various aspects of playback"
|
||||||
|
self.usage = "music [load]"
|
||||||
|
|
||||||
|
|
||||||
|
def loadTrack(self,args):
|
||||||
|
if len(args) == 0:
|
||||||
|
write("Usage: music load track")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args=None):
|
||||||
|
if args==None or len(args) < 1:
|
||||||
|
write(self.help)
|
||||||
|
return
|
||||||
|
|
||||||
|
if args[0] == "load":
|
||||||
|
self.loadTrack(args[1:])
|
||||||
|
|
||||||
|
elif args[0] == "play":
|
||||||
|
signal.emit("play")
|
||||||
|
|
||||||
|
elif args[0] == "pause":
|
||||||
|
signal.emit("pause")
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,13 @@ __author__="bjschuma"
|
||||||
__date__ ="$Jan 25, 2010 12:18:21 AM$"
|
__date__ ="$Jan 25, 2010 12:18:21 AM$"
|
||||||
|
|
||||||
|
|
||||||
|
from bt.message import write
|
||||||
from bt import plugin
|
from bt import plugin
|
||||||
import settings
|
import settings
|
||||||
settings.set("appname","ocarina2")
|
settings.set("appname","ocarina2")
|
||||||
|
|
||||||
from ct import db
|
from ct import db
|
||||||
|
from ct import gstreamer
|
||||||
|
|
||||||
|
|
||||||
class Plugin(plugin.Plugin):
|
class Plugin(plugin.Plugin):
|
||||||
|
@ -19,3 +21,8 @@ class Plugin(plugin.Plugin):
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
db.init()
|
db.init()
|
||||||
|
gstreamer.init()
|
||||||
|
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
gstreamer.close()
|
||||||
|
|
Loading…
Reference in New Issue