Example #1
0
    def do_play(self):
        """ Start playing the media file.

        Returns:
            `bool`: `True` iff this function should be run again (:func:`~GLib.idle_add` convention)
        """
        self.renderer = GstPlayer.PlayerVideoOverlayVideoRenderer()
        self.player = GstPlayer.Player.new(self.renderer)
        self.player.set_uri(self.uri)
        self.player.set_mute(self.muted)

        self.player.connect('state-changed', self.track_state)
        self.player.connect('duration-changed',
                            lambda p, ns: self.update_range(ns / 1e9))
        self.player.connect('position-updated',
                            lambda p, ns: self.update_progress(ns / 1e9))
        self.player.connect('end-of-stream',
                            lambda e: GLib.idle_add(self.hide))

        if self.renderer.get_window_handle():
            pass
        elif IS_WINDOWS:
            # TODO test in windows
            # get_property('window')
            self.renderer.set_window_handle(
                base.get_window_handle(self.movie_zone.get_window()))
        else:
            self.renderer.set_window_handle(
                self.movie_zone.get_window().get_xid())

        self.player.play()
        return False
Example #2
0
 def handle_embed(self, mapped_widget):
     """ Handler to embed the VLC player in the correct window, connected to the :attr:`~.Gtk.Widget.signals.map` signal
     """
     # Do we need to be on the main thread? (especially for the mess from the win32 window handle)
     #assert(isinstance(threading.current_thread(), threading._MainThread))
     if IS_WINDOWS:
         self.player.set_hwnd(
             base.get_window_handle(
                 self.movie_zone.get_window()))  # get_property('window')
     else:
         self.player.set_xwindow(self.movie_zone.get_window().get_xid())
     return False
Example #3
0
 def on_sync_message(self, bus, msg):
     """ Handle sync messages, in particular the one requesting the window handle (e.g. X11 window id)
     """
     window = self.movie_zone.get_window()
     if msg.get_structure().get_name() != 'prepare-window-handle':
         return
     elif window is None:
         logger.error('No window in which to embed the Gst player!')
     elif IS_WINDOWS:
         GLib.idle_add(lambda *args: msg.src.set_window_handle(
             base.get_window_handle(window)))
     else:
         GLib.idle_add(
             lambda *args: msg.src.set_window_handle(window.get_xid()))