简体   繁体   中英

Overlay Other GUI Elements Over GStreamer Video

I have a project built in Python, PyGTK 2.24, and PyGST (GStreamer). I have my video working perfectly in a gtk.DrawingArea object.

However, I need to display other GUI elements OVER this video while it is playing. (Please don't ask why, just trust me.) Right now, they all appear to be behind. In the code, the video objects (and gtk.DrawingArea) are declared and put into the gtk.Fixed FIRST, following by everything else.

So, how do I do this? Do I need to change what object GStreamer is playing on? I know it is possible...I've seen GStreamer programs that have things like buttons and labels sitting on top of the video.

Thanks in advance!

Probably of no use to the OP, but I searched for a long time looking for a way to place widgets over the top of a gtk.gdk.Drawable element (which could be a statically drawn image, animation or video) before I finally figured out how to do this in pygtk2.

Here's a link to what I came up with: http://bazaar.launchpad.net/~damien-moore/picty/trunk/view/642/modules/picty/overlay_widgets.py

This includes 3 custom classes:

ProportionalLayout: an implementation of a custom gtk.Container that lets the user position child widgets using proportions.

DrawableOverlay: an EventBox that emits a 'draw' event for the user to connect to and do drawing on, and displays a ProportionalLayout on top.

DrawableOverlayHover: a DrawableOverlayHover that only shows the widgets if the pointer gets "close" to them.

The sample main program illustrates how to use them. The code should be reasonably straightforward to adapt to a video application.

You can do this in GTK 3.2 and above using GtkOverlay .

If you can't upgrade, then here is a summary of the old-fashioned way: connect to the expose-event signal of the DrawingArea , and paint the information on yourself using Cairo. When the information changes, trigger a redraw of the drawing area using widget.queue_draw() . Make sure your handler runs after the handler that draws the actual video onto the drawing area. This will work for labels and non-interactive GUI elements.

If you want an actual functioning GUI element to hover above your video, that's rather more complicated and I don't know how to do it. I don't think Fixed guarantees any z-order. I suspect that your buttons and whatnot are being overpainted by the video being drawn onto the drawing area, so maybe triggering a redraw of those in your expose-event handler will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM