Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When should I call this method ‘mpv.terminate()’ #289

Closed
lzy-zj opened this issue Nov 16, 2024 · 1 comment
Closed

When should I call this method ‘mpv.terminate()’ #289

lzy-zj opened this issue Nov 16, 2024 · 1 comment

Comments

@lzy-zj
Copy link

lzy-zj commented Nov 16, 2024

for example:


class MpvWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.player = MPV(
            wid=str(int(self.winId())),

            log_handler=None,
            loglevel='debug'
        )

        # if i use this method, MpvWidget will not call __del__
        self.mpv.observe_property(
            'time-pos',
            lambda name, position: self._on_position_changed(position)
        )

    def __del__(self):
        self.player.terminate()
@lzy-zj lzy-zj changed the title a problem when working with pyqt5 When should I call this method ‘mpv.terminate()’ Nov 20, 2024
@jaseg
Copy link
Owner

jaseg commented Dec 21, 2024

You don't have to call terminate at all in this case. The underlying mpv instance is automatically destroyed when the MPV object is garbage collected. You only have to call terminate yourself when for some reason you want libmpv to release resources like window handles or when using OpenGL before the MPV object is automatically garbage collected.

@jaseg jaseg closed this as completed Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants