Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawingArea Cannot Get XID
    primarykey
    data
    text
    <p>I have the following Python 2.7/PyGObject 3.0/PyGST 0.10 module:</p> <pre><code>from gi.repository import Gtk, Gdk, GdkPixbuf import pango import pygst pygst.require('0.10') import gst import Trailcrest import os, sys import cairo from math import pi class Video: def __init__(self): def on_message(bus, message): if message.type == gst.MESSAGE_EOS: # End of Stream player.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 5000000000, gst.SEEK_TYPE_NONE, 6000000000) elif message.type == gst.MESSAGE_ERROR: player.set_state(gst.STATE_NULL) (err, debug) = message.parse_error() print "Error: %s" % err, debug def on_sync_message(bus, message): if message.structure is None: return False if message.structure.get_name() == "prepare-xwindow-id": Gdk.threads_enter() print "Run before" Gdk.Display.get_default().sync() print "Run after" win_id = videowidget.window.xid imagesink = message.src imagesink.set_property("force-aspect-ratio", True) imagesink.set_xwindow_id(win_id) Gtk.gdk.threads_leave() def click_me(event, data=None): player.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 5000000000, gst.SEEK_TYPE_NONE, 6000000000) win = Gtk.Window() win.set_resizable(False) win.set_decorated(False) win.set_position(Gtk.WindowPosition.CENTER) fixed = Gtk.Fixed() win.add(fixed) fixed.show() videowidget = Gtk.DrawingArea() fixed.put(videowidget, 0, 0) videowidget.set_size_request(640, 480) videowidget.show() # Setup GStreamer player = gst.element_factory_make("playbin", "MultimediaPlayer") bus = player.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() #used to get messages that GStreamer emits bus.connect("message", on_message) #used for connecting video to your application bus.connect("sync-message::element", on_sync_message) player.set_property("uri", "file://" + os.getcwd() + "/VID/BGA-HABT-001.ogv") player.set_state(gst.STATE_PLAYING) win.show() def main(): Gdk.threads_enter() Gtk.main() return 0 if __name__ == "__main__": Video() main() </code></pre> <p>I am always getting this error, along with the video opening in a new window, instead of the existing window.</p> <blockquote> <p>Traceback (most recent call last): File "video.py", line 32, in on_sync_message win_id = videowidget.window.xid AttributeError: 'DrawingArea' object has no attribute 'window'</p> </blockquote> <p>How do I fix this, so the video displays in the window I created, instead of a new one?</p> <p>By the by, this problem only started occuring after I switched to PyGObject 3.0 from PyGTK 2.24.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload