[Pyxine-checkins] pyxine/pyxine player.py,NONE,1.1 Makefile,1.2,1.3 __init__.py,1.1.1.1,1.2
Status: Pre-Alpha
Brought to you by:
dairiki
|
From: <da...@us...> - 2003-02-13 19:51:31
|
Update of /cvsroot/pyxine/pyxine/pyxine
In directory sc8-pr-cvs1:/tmp/cvs-serv15179/pyxine
Modified Files:
Makefile __init__.py
Added Files:
player.py
Log Message:
Abstract some higher-level playing functionality into new class
pyxine.player.Player.
--- NEW FILE: player.py ---
# $Id: player.py,v 1.1 2003/02/13 19:51:27 dairiki Exp $
#
# Copyright (C) 2003 Geoffrey T. Dairiki <da...@da...>
#
# This file is part of Pyxine, Python bindings for xine.
#
# Pyxine is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# Pyxine is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Generic higher-level multimedia player support
"""
# FIXME: include a log in the distribution
LOGO = "/usr/share/xine/skins/xine-ui_logo.mpv"
class Player:
"""Mixin which adds higher level player control methods.
"""
__stream = None
__listener = None
__logo = LOGO
__mrl = None
def __init__(self, stream=None, logo=LOGO):
self.__logo = logo
if (stream):
self.set_stream(stream)
def set_stream(self, stream):
self.__stream = stream
if stream:
self.__listener = stream.new_event_listener(self.__xine_event_cb)
self.stop()
else:
self.__listener = None
def __xine_event_cb(self, event):
if event.type == "FRAME_FORMAT_CHANGE":
# FIXME:?
self.frame_format_change(event.data)
elif event.type == "UI_PLAYBACK_FINISHED":
self.stop()
def frame_format_change(self, event_data):
pass
def play(self, mrl):
stream = self.__stream
stream.close()
stream.open(mrl)
self.__mrl = mrl
if stream.has_video:
# disconnect any audio visualization post plugin
stream.audio_source.wire(stream.ao)
else:
self.__visualize_audio("goom")
stream.play()
def __visualize_audio(self, post_name="goom"):
stream = self.__stream
from pyxine import post
goom = post.Post(stream, post_name,
audio_target=stream.ao,
video_target=stream.vo)
stream.audio_source.wire(goom.inputs["audio in"])
def stop(self):
stream = self.__stream
if self.__mrl != self.__logo:
self.play(self.__logo)
def pause(self, do_pause="TOGGLE"):
stream = self.__stream
if do_pause == "TOGGLE":
do_pause = stream.speed != "PAUSE"
stream.speed = do_pause and "PAUSE" or "NORMAL";
# FIXME: % or secs
def seek(self, pos):
stream = self.__stream
stream.stop()
stream.play(pos)
# FIXME: % or secs?
def seekrel(self, secs):
stream = self.__stream
pos = stream.get_pos_length()[1]
stream.stop()
stream.play(start_time = pos + secs)
Index: Makefile
===================================================================
RCS file: /cvsroot/pyxine/pyxine/pyxine/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile 8 Feb 2003 00:51:45 -0000 1.2
+++ Makefile 13 Feb 2003 19:51:27 -0000 1.3
@@ -24,7 +24,7 @@
PYSOURCE = config.py constants.py constwrap.py cstruct.py
PYSOURCE += event.py __init__.py osd.py post.py
-PYSOURCE += weakmethod.py x11.py xine.py
+PYSOURCE += weakmethod.py x11.py xine.py player.py
GEN_FILES = libxine_wrap.c pxlib.py
DIST_FILES= Makefile libxine.i fixed_xine.h orig_xine.h
Index: __init__.py
===================================================================
RCS file: /cvsroot/pyxine/pyxine/pyxine/__init__.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- __init__.py 8 Feb 2003 00:42:20 -0000 1.1.1.1
+++ __init__.py 13 Feb 2003 19:51:27 -0000 1.2
@@ -18,7 +18,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-__all__ = [ 'constants', 'xine', 'x11', 'stream' ]
+__all__ = [ 'constants', 'xine', 'x11',
+ 'osd', 'post', 'player', 'weakmethod' ]
+
class Error(Exception):
"""Base exception class for exceptions raised by pyxine.
|