Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-06-30 12:22:24 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-06-30 12:22:24 (GMT)
commit1a77dd8554a7675796d89b0181b05934e7358a30 (patch)
tree1690685b264b798886223c55a87e0319c987e1c3 /utils
parentbda377de6245d20a7cd894ed94fea97cfca6f971 (diff)
using separate utilities for audio vs movies to avoid phantom window problem on XO
Diffstat (limited to 'utils')
-rw-r--r--utils/play_audio.py (copied from utils/gplay.py)109
-rw-r--r--utils/play_video.py (renamed from utils/gplay.py)48
2 files changed, 35 insertions, 122 deletions
diff --git a/utils/gplay.py b/utils/play_audio.py
index a1a5dc6..f5e08b5 100644
--- a/utils/gplay.py
+++ b/utils/play_audio.py
@@ -1,10 +1,10 @@
"""
- tagplay.py
+ aplay.py
refactored based on Jukebox Activity
Copyright (C) 2007 Andy Wingo <wingo@pobox.com>
Copyright (C) 2007 Red Hat, Inc.
Copyright (C) 2008-2010 Kushal Das <kushal@fedoraproject.org>
- Copyright (C) 2010-2011 Walter Bender
+ Copyright (C) 2010-11 Walter Bender
"""
# This program is free software; you can redistribute it and/or
@@ -41,76 +41,30 @@ import urllib
def play_audio_from_file(parent, file_path):
- """ Called from Show block of audio media """
- if parent.gplay is not None and parent.gplay.player is not None:
- if parent.gplay.player.playing:
- parent.gplay.player.stop()
- if parent.gplay.bin is not None:
- parent.gplay.bin.destroy()
+ """ Audio media """
+ parent.aplay = Aplay()
+ parent.aplay.start(file_path)
- parent.gplay = Gplay(gtk.gdk.screen_width(), gtk.gdk.screen_height(), 4, 3)
- parent.gplay.start(file_path)
-
-def play_movie_from_file(parent, filepath, x, y, w, h):
- """ Called from Show block of video media """
- if parent.gplay is not None and parent.gplay.player is not None:
- if parent.gplay.player.playing:
- parent.gplay.player.stop()
- if parent.gplay.bin is not None:
- parent.gplay.bin.destroy()
-
- parent.gplay = Gplay(x, y, w, h)
- parent.gplay.start(filepath)
-
-
-def stop_media(parent):
- """ Called from Clean block and toolbar Stop button """
- if parent.gplay == None:
- return
-
- if parent.gplay.player is not None:
- parent.gplay.player.stop()
- if parent.gplay.bin != None:
- parent.gplay.bin.destroy()
-
- parent.gplay = None
-
-
-def media_playing(parent):
- if parent.gplay == None:
- return False
- return parent.gplay.player.is_playing()
-
-
-class Gplay():
+class Aplay():
UPDATE_INTERVAL = 500
- def __init__(self, x=0, y=0, w=0, h=0):
+ def __init__(self):
self.player = None
self.uri = None
self.playlist = []
self.jobjectlist = []
self.playpath = None
+ self.only_audio = True
self.got_stream_info = False
self.currentplaying = 0
- self.bin = gtk.Window()
-
self.videowidget = VideoWidget()
- self.bin.add(self.videowidget)
- self.bin.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
- self.bin.set_decorated(False)
-
- self.bin.move(int(x), int(y))
- self.bin.resize(int(w), int(h))
- self.bin.show_all()
-
self._want_document = True
def _player_eos_cb(self, widget):
- logging.debug('end of stream')
+ pass
def _player_error_cb(self, widget, message, detail):
self.player.stop()
@@ -122,6 +76,12 @@ class Gplay():
return
GST_STREAM_TYPE_VIDEO = 2
+
+ only_audio = True
+ for item in stream_info:
+ if item.props.type == GST_STREAM_TYPE_VIDEO:
+ only_audio = False
+ self.only_audio = only_audio
self.got_stream_info = True
def start(self, uri=None):
@@ -213,48 +173,13 @@ class GstPlayer(gobject.GObject):
self.player.props.stream_info_value_array)
def _init_video_sink(self):
- self.bin = gst.Bin()
- videoscale = gst.element_factory_make('videoscale')
- self.bin.add(videoscale)
- pad = videoscale.get_pad('sink')
- ghostpad = gst.GhostPad('sink', pad)
- self.bin.add_pad(ghostpad)
- videoscale.set_property('method', 0)
-
- caps_string = 'video/x-raw-yuv, '
- r = self.videowidget.get_allocation()
- if r.width > 500 and r.height > 500:
- # Sigh... xvimagesink on the XOs will scale the video to fit
- # but ximagesink in Xephyr does not. So we live with unscaled
- # video in Xephyr so that the XO can work right.
- w = 480
- h = float(w) / float(float(r.width) / float(r.height))
- caps_string += 'width=%d, height=%d' % (w, h)
- else:
- caps_string += 'width=480, height=360'
-
- caps = gst.Caps(caps_string)
- self.filter = gst.element_factory_make('capsfilter', 'filter')
- self.bin.add(self.filter)
- self.filter.set_property('caps', caps)
-
- conv = gst.element_factory_make('ffmpegcolorspace', 'conv')
- self.bin.add(conv)
- videosink = gst.element_factory_make('autovideosink')
- self.bin.add(videosink)
- gst.element_link_many(videoscale, self.filter, conv, videosink)
- self.player.set_property('video-sink', self.bin)
-
- def pause(self):
- self.player.set_state(gst.STATE_PAUSED)
- self.playing = False
- logging.debug('pausing player')
+ return
def play(self):
self.player.set_state(gst.STATE_PLAYING)
self.playing = True
self.error = False
- logging.debug('playing player')
+ # logging.debug('playing player')
def stop(self):
self.player.set_state(gst.STATE_NULL)
diff --git a/utils/gplay.py b/utils/play_video.py
index a1a5dc6..d1e1020 100644
--- a/utils/gplay.py
+++ b/utils/play_video.py
@@ -1,5 +1,5 @@
"""
- tagplay.py
+ play_video.py
refactored based on Jukebox Activity
Copyright (C) 2007 Andy Wingo <wingo@pobox.com>
Copyright (C) 2007 Red Hat, Inc.
@@ -40,50 +40,38 @@ import gtk
import urllib
-def play_audio_from_file(parent, file_path):
- """ Called from Show block of audio media """
- if parent.gplay is not None and parent.gplay.player is not None:
- if parent.gplay.player.playing:
- parent.gplay.player.stop()
- if parent.gplay.bin is not None:
- parent.gplay.bin.destroy()
-
- parent.gplay = Gplay(gtk.gdk.screen_width(), gtk.gdk.screen_height(), 4, 3)
- parent.gplay.start(file_path)
-
-
def play_movie_from_file(parent, filepath, x, y, w, h):
- """ Called from Show block of video media """
- if parent.gplay is not None and parent.gplay.player is not None:
- if parent.gplay.player.playing:
- parent.gplay.player.stop()
- if parent.gplay.bin is not None:
- parent.gplay.bin.destroy()
+ """ Video media """
+ if parent.vplay is not None and parent.vplay.player is not None:
+ if parent.vplay.player.playing:
+ parent.vplay.player.stop()
+ if parent.vplay.bin is not None:
+ parent.vplay.bin.destroy()
- parent.gplay = Gplay(x, y, w, h)
- parent.gplay.start(filepath)
+ parent.vplay = Vplay(x, y, w, h)
+ parent.vplay.start(filepath)
def stop_media(parent):
""" Called from Clean block and toolbar Stop button """
- if parent.gplay == None:
+ if parent.vplay == None:
return
- if parent.gplay.player is not None:
- parent.gplay.player.stop()
- if parent.gplay.bin != None:
- parent.gplay.bin.destroy()
+ if parent.vplay.player is not None:
+ parent.vplay.player.stop()
+ if parent.vplay.bin != None:
+ parent.vplay.bin.destroy()
- parent.gplay = None
+ parent.vplay = None
def media_playing(parent):
- if parent.gplay == None:
+ if parent.vplay == None:
return False
- return parent.gplay.player.is_playing()
+ return parent.vplay.player.is_playing()
-class Gplay():
+class Vplay():
UPDATE_INTERVAL = 500
def __init__(self, x=0, y=0, w=0, h=0):