examples/gstplay: Removed examples for old gstplay.

Original commit message from CVS:
2005-07-12  Andy Wingo  <wingo@pobox.com>

* examples/gstplay: Removed examples for old gstplay.
This commit is contained in:
Andy Wingo 2005-07-12 13:15:26 +00:00
parent 6af81f9d04
commit 8136f42910
4 changed files with 4 additions and 203 deletions

View file

@ -1,3 +1,7 @@
2005-07-12 Andy Wingo <wingo@pobox.com>
* examples/gstplay: Removed examples for old gstplay.
2005-07-12 Edward Hervey <edward@fluendo.com>
* gst/gstmessage.override:

View file

@ -1,6 +0,0 @@
examplesdir = $(pkgdatadir)/examples
examples_DATA = \
player.py \
videoplayer.py
EXTRA_DIST = $(examples_DATA)

View file

@ -1,68 +0,0 @@
#!/usr/bin/env python
#
# Copyright (C) 2004 David I. Lehn
# 2004 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
import sys
import gst
import gst.play
def nano2str(nanos):
ts = nanos / gst.SECOND
return '%02d:%02d:%02d.%06d' % (ts / 3600,
ts / 60,
ts % 60,
nanos % gst.SECOND)
def stream_length_cb(play, ns):
print 'stream length: %s' % nano2str(ns)
def have_video_size_cb(play, w, h):
print 'video size %d %d' % (w, h)
def found_tag_cb(play, src, tags):
for tag in tags.keys():
print "%s: %s" % (gst.tag_get_nick(tag), tags[tag])
def main(args):
if len(args) != 2:
print 'Usage: %s file' % args[0]
return -1
filename = args[1]
play = gst.play.Play()
play.connect('stream-length', stream_length_cb)
play.connect('have-video-size', have_video_size_cb)
play.connect('found-tag', found_tag_cb)
play.connect('eos', lambda p: gst.main_quit())
# Setup source and sinks
play.set_data_src(gst.element_factory_make('filesrc'))
play.set_audio_sink(gst.element_factory_make('osssink'))
play.set_video_sink(gst.element_factory_make('fakesink'))
# Point location to our filename
play.set_location(filename)
# Start playing the stream
play.set_state(gst.STATE_PLAYING)
gst.main()
if __name__ == '__main__':
sys.exit(main(sys.argv))

View file

@ -1,129 +0,0 @@
#!/usr/bin/env python
import sys
import pygtk
pygtk.require('2.0')
import gtk
if gtk.pygtk_version < (2,3,91):
raise SystemExit, "PyGTK 2.3.91 or higher required"
import gst.play
import gst.interfaces
class Player(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.connect('delete-event', self.delete_event_cb)
self.set_size_request(640, 480)
vbox = gtk.VBox()
self.add(vbox)
accelgroup = gtk.AccelGroup()
self.add_accel_group(accelgroup)
self.item_factory = gtk.ItemFactory(gtk.MenuBar, '<main>', accelgroup)
menu_items = [
('/_File', None, None, 0, '<Branch>' ),
('/File/_Open', '<control>O', self.file_open_cb, 0, ''),
('/File/sep1', None, None, 0, '<Separator>'),
('/File/_Quit', '<control>Q', self.file_quit_cb, 0, ''),
]
self.item_factory.create_items(menu_items)
menubar = self.item_factory.get_widget('<main>')
vbox.pack_start(menubar, expand=False)
self.player = PlayerWidget(self)
vbox.pack_start(self.player, expand=True)
hbox = gtk.HBox()
vbox.pack_start(hbox, expand=False)
button = gtk.Button('Play')
button.connect('clicked', self.play_clicked_cb)
hbox.pack_start(button, expand=False)
button.set_size_request(120, -1)
button.set_border_width(5)
self.play_button = button
button = gtk.Button('Stop')
button.connect('clicked', self.stop_clicked_cb)
hbox.pack_start(button, expand=False)
button.set_size_request(120, -1)
button.set_border_width(5)
self.stop_button = button
def file_open_cb(self, button, event):
fs = gtk.FileSelection('Open a file')
response = fs.run()
if response == gtk.RESPONSE_OK:
self.player.set_filename(fs.get_filename())
fs.destroy()
self.player.play()
self.play_button.set_label('Pause')
def file_quit_cb(self, button, event):
gst.main_quit()
def play_clicked_cb(self, button):
if self.player.is_playing():
self.player.pause()
button.set_label('Play')
else:
self.player.play()
button.set_label('Pause')
def stop_clicked_cb(self, button):
self.player.stop()
def delete_event_cb(self, *args):
self.player.stop()
gst.main_quit()
class PlayerWidget(gtk.DrawingArea):
def __init__(self, parent):
self.parentw = parent
gtk.DrawingArea.__init__(self)
self.connect('destroy', self.destroy_cb)
self.connect('expose-event', self.expose_cb)
self.set_size_request(400, 400)
self.player = gst.play.Play()
self.player.connect('eos', lambda p: gst.main_quit())
self.imagesink = gst.element_factory_make('xvimagesink')
# Setup source and sinks
self.player.set_data_src(gst.element_factory_make('filesrc'))
audio_sink = gst.element_factory_make('alsasink')
audio_sink.set_property('device', 'hw:0')
self.player.set_audio_sink(audio_sink)
self.player.set_video_sink(self.imagesink)
def destroy_cb(self, da):
self.imagesink.set_xwindow_id(0L)
def expose_cb(self, window, event):
self.imagesink.set_xwindow_id(self.window.xid)
def stop(self):
self.player.set_state(gst.STATE_NULL)
def play(self):
self.imagesink.set_xwindow_id(self.window.xid)
self.player.set_state(gst.STATE_PLAYING)
def pause(self):
self.player.set_state(gst.STATE_PAUSED)
def is_playing(self):
return self.player.get_state() == gst.STATE_PLAYING
def set_filename(self, filename):
self.player.set_location(filename)
player = Player()
player.show_all()
gst.main()