def __init__(self, mpv_commands_async: bool, **properties): super().__init__(**properties) self.mpv_commands_async = mpv_commands_async self._proc_addr_wrapper = OpenGlCbGetProcAddrFn(get_process_address) self.ctx = None self.mpv = MPV(input_default_bindings=True, input_vo_keyboard=True, osc=True # log_handler=print, # loglevel='debug' ) self.connect("realize", self.on_realize) self.connect("render", self.on_render) self.connect("unrealize", self.on_unrealize) self.add_events(Gdk.EventMask.POINTER_MOTION_MASK) self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK) # self.add_events(Gdk.EventMask.KEY_PRESS_MASK) # self.add_events(Gdk.EventMask.STRUCTURE_MASK) # self.add_events(Gdk.EventMask.SCROLL_MASK) self.connect("motion-notify-event", self.on_mouse_move_event) self.connect("button-press-event", self.on_button_press_event) self.connect("button-release-event", self.on_button_release_event)
def __init__(self, parent=None): super().__init__(parent=parent) self.mpv = MPV(vo='opengl-cb', ytdl=True) self.mpv_gl = _mpv_get_sub_api(self.mpv.handle, MpvSubApi.MPV_SUB_API_OPENGL_CB) self.on_update_c = OpenGlCbUpdateFn(self.on_update) self.on_update_fake_c = OpenGlCbUpdateFn(self.on_update_fake) self.get_proc_addr_c = OpenGlCbGetProcAddrFn(get_proc_addr) _mpv_opengl_cb_set_update_callback(self.mpv_gl, self.on_update_c, None) self.frameSwapped.connect(self.swapped, Qt.DirectConnection)
def __init__(self, app, parent=None): super().__init__(parent=parent) self._app = app self.mpv_gl = _mpv_get_sub_api(app.player._mpv.handle, MpvSubApi.MPV_SUB_API_OPENGL_CB) self.on_update_c = OpenGlCbUpdateFn(self.on_update) self.on_update_fake_c = OpenGlCbUpdateFn(self.on_update_fake) self.get_proc_addr_c = OpenGlCbGetProcAddrFn(get_proc_addr) self.frameSwapped.connect(self.swapped) self._mpv_gl_inited = False
def __init__(self, parent=None, ui=None, logr=None, tmp=None): global gui, MainWindow, screen_width, screen_height, logger print(ui, logr, tmp, "--") super().__init__(parent) gui = ui self.ui = ui MainWindow = parent logger = logr self.mpv_gl = _mpv_get_sub_api(self.mpv.handle, MpvSubApi.MPV_SUB_API_OPENGL_CB) self.on_update_c = OpenGlCbUpdateFn(self.on_update) self.on_update_fake_c = OpenGlCbUpdateFn(self.on_update_fake) self.get_proc_addr_c = OpenGlCbGetProcAddrFn(get_proc_addr) _mpv_opengl_cb_set_update_callback(self.mpv_gl, self.on_update_c, None) self.frameSwapped.connect(self.swapped, Qt.DirectConnection) self.arrow_timer = QtCore.QTimer() self.arrow_timer.timeout.connect(self.arrow_hide) self.arrow_timer.setSingleShot(True) self.pause_timer = QtCore.QTimer() self.pause_timer.timeout.connect(self.pause_unpause) self.pause_timer.setSingleShot(True) self.fs_timer = QtCore.QTimer() self.fs_timer.timeout.connect(self.toggle_fullscreen_mode) self.fs_timer.setSingleShot(True) self.player_val = "libmpv" screen_width = gui.screen_size[0] screen_height = gui.screen_size[1] self.custom_keys = {} self.event_dict = {'ctrl': False, 'alt': False, 'shift': False} self.key_map = KeyBoardShortcuts(gui, self) self.mpv_default = self.key_map.get_default_keys() self.mpv_custom, self.input_conf_list = self.key_map.get_custom_keys( gui.mpv_input_conf) self.custom_keys, _ = self.key_map.get_custom_keys(gui.custom_key_file) self.function_map = self.key_map.function_map() self.non_alphanumeric_keys = self.key_map.non_alphanumeric_keys() self.alphanumeric_keys = self.key_map.alphanumeric_keys() if self.custom_keys: self.mpv_default = self.custom_keys.copy() self.shift_keys = [ '?', '>', '<', '"', ':', '}', '{', '|', '+', '_', 'sharp', ')', '(', '*', '&', '^', '%', '$', '#', '#', '@', '!', '~' ] self.aboutToResize.connect(self.resized) self.aboutToCompose.connect(self.compose)
def __init__(self, filename): self.filename = filename self.open = True self.fbo = gl.glGenFramebuffers(1) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.fbo) self.texture = gl.glGenTextures(1) gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glFramebufferTexture2D(gl.GL_FRAMEBUFFER, gl.GL_COLOR_ATTACHMENT0, gl.GL_TEXTURE_2D, self.texture, 0) gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, 100, 100, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, None) gl.glBindTexture(gl.GL_TEXTURE_2D, 0) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0) self.playbackPos = (0, ) self.volume = (0, ) self.loop = 'inf' self.mpv = MPV(log_handler=print, loglevel='debug') def get_process_address(_, name): print(name) address = glfw.get_proc_address(name.decode('utf8')) return ctypes.cast(address, ctypes.c_void_p).value proc_addr_wrapper = OpenGlCbGetProcAddrFn(get_process_address) self.ctx = MpvRenderContext( self.mpv, 'opengl', opengl_init_params={'get_proc_address': proc_addr_wrapper}) self.mpv.play(self.filename) self.mpv.volume = 0
def __init__(self, api: Api, parent: Optional[QWidget] = None) -> None: super().__init__(parent) self._api = api locale.setlocale(locale.LC_NUMERIC, "C") self._destroyed = False self._need_subs_refresh = False self.mpv = MPV(vo="opengl-cb", ytdl=False, loglevel="info", log_handler=print) self.mpv_gl = _mpv_get_sub_api(self.mpv.handle, MpvSubApi.MPV_SUB_API_OPENGL_CB) self.on_update_c = OpenGlCbUpdateFn(self.on_update) self.on_update_fake_c = OpenGlCbUpdateFn(self.on_update_fake) self.get_proc_addr_c = OpenGlCbGetProcAddrFn(get_proc_addr) _mpv_opengl_cb_set_update_callback(self.mpv_gl, self.on_update_c, None) self.frameSwapped.connect(self.swapped, Qt.ConnectionType.DirectConnection) for key, value in { # "config": False, "quiet": False, "msg-level": "all=info", "osc": False, "osd-bar": False, "input-cursor": False, "input-vo-keyboard": False, "input-default-bindings": False, "ytdl": False, "sub-auto": False, "audio-file-auto": False, "vo": "null" if api.args.no_video else "libmpv", "hwdec": "no", "pause": True, "idle": True, "blend-subtitles": "video", "video-sync": "display-vdrop", "keepaspect": True, "stop-playback-on-init-failure": False, "keep-open": True, "track-auto-selection": False, }.items(): setattr(self.mpv, key, value) self._opengl = None self._timer = QTimer(parent=None) self._timer.setInterval(api.cfg.opt["video"]["subs_sync_interval"]) self._timer.timeout.connect(self._refresh_subs_if_needed) api.subs.loaded.connect(self._on_subs_load) api.video.stream_created.connect(self._on_video_state_change) api.video.stream_unloaded.connect(self._on_video_state_change) api.video.current_stream_switched.connect(self._on_video_state_change) api.audio.stream_created.connect(self._on_audio_state_change) api.audio.stream_unloaded.connect(self._on_audio_state_change) api.audio.current_stream_switched.connect(self._on_audio_state_change) api.playback.request_seek.connect(self._on_request_seek, Qt.ConnectionType.DirectConnection) api.playback.request_playback.connect(self._on_request_playback) api.playback.playback_speed_changed.connect( self._on_playback_speed_change) api.playback.volume_changed.connect(self._on_volume_change) api.playback.mute_changed.connect(self._on_mute_change) api.playback.pause_changed.connect(self._on_pause_change) api.video.view.zoom_changed.connect(self._on_video_zoom_change) api.video.view.pan_changed.connect(self._on_video_pan_change) api.gui.terminated.connect(self.shutdown) self._schedule_update.connect(self.update) self.mpv.observe_property("time-pos", self._on_mpv_time_pos_change) self.mpv.observe_property("track-list", self._on_mpv_track_list_change) self.mpv.observe_property("pause", self._on_mpv_pause_change) self._timer.start()
def __init__(self, app, parent=None): super().__init__(app=app, parent=parent) self._app = app self.mpv = self._app.player._mpv # noqa self.ctx = None self.get_proc_addr_c = OpenGlCbGetProcAddrFn(get_proc_addr)
def __init__(self, parent=None): super().__init__(parent=parent) self.mpv = MPV(ytdl=True) self.ctx = None self.get_proc_addr_c = OpenGlCbGetProcAddrFn(get_proc_addr)