Skip to content

Commit

Permalink
Attempt to improve VLC glitching fix #227
Browse files Browse the repository at this point in the history
See also #225 and d99a7d7.
  • Loading branch information
Cimbali committed Nov 16, 2021
1 parent 383ad94 commit 8ff6a7a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion pympress/media_overlays/vlc_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, *args, **kwargs):

super(VlcOverlay, self).__init__(*args, **kwargs)
# Simple black background painting to avoid glitching outside of video area
self.movie_zone.connect('draw', lambda widget, context: context.paint())
self.movie_zone.connect('draw', self.paint_backdrop)

event_manager = self.player.event_manager()
event_manager.event_attach(vlc.EventType.MediaPlayerEndReached, lambda e: GLib.idle_add(self.handle_end))
Expand All @@ -98,6 +98,7 @@ def handle_embed(self, mapped_widget):
self.player.set_hwnd(get_window_handle(window)) # get_property('window')
else:
self.player.set_xwindow(window.get_xid())
self.movie_zone.queue_draw()
return False


Expand Down Expand Up @@ -147,9 +148,31 @@ def do_play(self):
`bool`: `True` iff this function should be run again (:func:`~GLib.idle_add` convention)
"""
self.player.play()
self.movie_zone.queue_draw()
return False


def paint_backdrop(self, widget, context):
""" Draw behind/around the video, aka the black bars
Args:
widget (:class:`~Gtk.Widget`): the widget to update
context (:class:`~cairo.Context`): the Cairo context (or `None` if called directly)
"""
context.save()
context.set_source_rgb(0, 0, 0)
context.fill()
context.paint()
context.restore()


def show(self):
""" Bring the widget to the top of the overlays if necessary − also force redraw of movie zone
"""
super(VlcOverlay, self).show()
self.movie_zone.queue_draw()


def do_play_pause(self):
""" Toggle pause mode of the media.
Expand Down

0 comments on commit 8ff6a7a

Please sign in to comment.