Skip to content

Commit

Permalink
[Cocoa] Fix playing video after closing window
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0r committed Oct 16, 2023
1 parent 4928669 commit d22ac84
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions webview/platforms/cocoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ def windowWillClose_(self, notification):
if i.pywebview_window in windows:
windows.remove(i.pywebview_window)

i.webkit.setNavigationDelegate_(None)
i.webkit.setUIDelegate_(None)

# this seems to be a bug in WkWebView, so we need to load blank html
# see https://stackoverflow.com/questions/27410413/wkwebview-embed-video-keeps-playing-sound-after-release
i.webkit.loadHTMLString_baseURL_('', None)
i.webkit.removeFromSuperview()
i.webkit = None

i.closed.set()

if BrowserView.instances == {}:
Expand Down

0 comments on commit d22ac84

Please sign in to comment.