Skip to content

tkinter embedding: mpv.terminate() hangs when observe_property has been added to time-pos #114

Open
@dfaker

Description

@dfaker

Reproducible on windows 10 with python-mpv 0.4.6 and mpv-dev-x86_64-20200426-git-640db1e, the last print statement in this snippet is never reached:

import tkinter as tk
import mpv

root=tk.Tk()

player = mpv.MPV(wid=str(int(root.winfo_id())))
player.play('out.mp4')

def handlePropertyChange(name,value):
  print('property change',name,value)
  root.title(str(value))

player.observe_property('time-pos', handlePropertyChange)
tk.mainloop()

print('calling player.terminate.')
player.terminate()
print('terminate player.returned.')

The same behaviour isn't noted if osd-width or duration is observed, additionally placing a player.unobserve_property('time-pos', handlePropertyChange) directly before player.terminate() has no effect, however removing it ahead of time,presumably giving enough time for the event queue to empty does seem to work:

import tkinter as tk
import mpv

root=tk.Tk()

player = mpv.MPV(wid=str(int(root.winfo_id())))

player.play('out.mp4')

def handlePropertyChange(name,value):
  print('property change',name,value)
  root.title(str(value))
  if value is not None and value > 5:
    player.unobserve_property('time-pos', handlePropertyChange)

player.observe_property('time-pos', handlePropertyChange)

tk.mainloop()

print('calling player.terminate.')
player.terminate()
print('terminate player.returned.')

Does the event loop stop working when the frame with the wid passed to mpv is destroyed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions