Exemple #1
0
 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)
Exemple #2
0
    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)
Exemple #4
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()