ocarina/src/core/gstreamer.py

73 lines
1.2 KiB
Python

# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Dec 21, 2009 11:58:37 PM$"
global name, app, type, path, opt
name = "gstreamer"
app = "ocarina"
type = "core"
path = ""
opt = []
from bt.file import *
import gst
import settings
global pipeline
pipeline = None
def load(filename):
filename = expandPath(filename)
if checkPath(filename) == False:
return
write("loading file: "+filename)
bin = gst.element_factory_make("playbin", None)
bin.set_property("uri", "file://"+filename)
bin.set_state(gst.STATE_PAUSED)
global pipeline
pipeline = gst.Pipeline("player")
pipeline.add(bin)
def play():
global pipeline
pipeline.set_state(gst.STATE_PLAYING)
def pause():
global pipeline
pipeline.set_state(gst.STATE_PAUSED)
# Called every time the plugin is enabled
def open():
global pipeline
pipeline = gst.Pipeline()
pipeline.set_state(gst.STATE_NULL)
songs = settings.get("args")
if len(songs) > 0:
load(songs[0])
settings.replace("args", [])
# Called every time the plugin is stopped
def close():
global pipeline
pipeline.set_state(gst.STATE_NULL)
# Called when the plugin needs to perform some action
def run(args=None):
pass