Skip to content

If you have multiple scripts connected to the same mpv instance they all receive keypresses #13

Description

@TingTingin

If you have multiple scripts connected to the same mpv instance they all receive keypresses

self.keybind_id = 1
changing to self.keybind = time.time_ns() could make it so that ids are more unique to avoid clashes

Activity

  1. TingTingin commented on Jun 29, 2022

    @TingTingin
    Author

    could also use uuid1().int but dont know if thats overkill

  2. chapmanjacobd commented on Oct 4, 2023

    @chapmanjacobd

    It seems like terminating an mpv instance from a different mpv instance also has a problem. a thread stays open:

    left_mpv.quit_callback = right_mpv.terminate
    right_mpv.quit_callback = left_mpv.terminate
    

    for example:

    from python_mpv_jsonipc import MPV
    
    def auto_seek(x_mpv, delay=0.0):
        x_mpv.wait_for_property('duration')
        time.sleep(delay)
        while True:
            for _ in range(20):
                x_mpv.command("seek", "0.2", "relative-percent")
                time.sleep(0.05)
            for _ in range(5):
                x_mpv.command("seek", "3", "relative-percent")
                time.sleep(1.2)
    
    left_mpv = MPV()
    right_mpv = MPV()
    
    left_mpv.play(left_side)
    right_mpv.play(right_side)
    
    left_mpv.quit_callback = right_mpv.terminate
    right_mpv.quit_callback = left_mpv.terminate
    
    with ThreadPoolExecutor() as e:
        e.submit(auto_seek, left_mpv)
        e.submit(auto_seek, right_mpv, delay=0.4)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions