@influencia@mysaturnday thank you, that was very helpful. I could reproduce the issue with mpv video player on Windows when Anki is no longer responding and can only be closed with the Task Manager.
I could reproduce it with the packaged mpv version and with the latest mpv version. It’s a bit random, though with the latest mpv version it seems to happen more frequently. I used a deck with one card and ~3 seconds video for testing. I clicked the audio play button, the video file started playing, went back to Google Chrome, and when the video file stopped playing clicked Anki icon in the taskbar, and if Anki was still responding clicked the audio play button again and went back to Google Chrome. Sometimes it happened on the 3rd try, sometimes on 5th or 10th, but sometimes I couldn’t reproduce it and restarted Anki to try again.
@influencia I believe you’re talking about the same problem as @mysaturnday , i.e. the main Anki window is still there, but it’s greyed out and you can’t click on anything. It should be scenario 1 (“when the video is over”) and scenario 3 (“use the X button to close the video”).
@influencia and @mysaturnday for now please try to install the add-on “Video Fix 1” - https://ankiweb.net/shared/info/1006287781 - restart Anki and let me know if it still happens. The add-on will tell Anki to create a new mpv.exe process every time to play the audio or video file. It seems to work for me but I haven’t tested it very much.
@influencia If mpv crashes in the middle of the video playback (probably scenario 2), try to update your graphics card driver, restart your PC and install the latest mpv version.
There is another problem with the new player: it doesn’t respond to shorcated buttons. Sometimes it can only respond to “space” but sometimes it just “passes” the actual cart, and what’s more, after switching to a new card, it doesn’t close automatically. The problem is also that “escape” doesn’t work anymore for closing player, and what’s more frustrating, if it’s an audio card, i can’t even pause the sound.
I attached this three non-functional buttons in the next screenshot.
Sorry, I didn’t think about the hotkeys and the hotkeys won’t work with “Video Fix 1”. Though it should still close automatically if you move to the next card and Tools - Preferences - “Interrupt current audio when answering” is checked.
The “q” button can be used to close the video player, but the issue with the space bar seems to be caused by mpv window isn’t being active sometimes, i.e. focused, and it’s something that needs to be investigated alongside with the original issue when Anki is no longer responding after the video is closed.
I’d suggest to install the alternate Anki version for now. There should be no noticeable differences on Windows and it’s packaged with mplayer and should work as it used to be in earlier Anki versions.
Maybe install 2.1.34-alternate for now as mplayer doesn’t seem to cause the freezing issue.
About media sync, I’d recommend to watch new intro videos about syncing.
And if I correctly understood the issue with the hotkeys, they only work in Anki, i.e. they should work just fine with the audio file, but with the video file the hotkeys will only work if Anki window is active, i.e. focused.
The freezing issue is yet to be investigated. I tried a different backend for mpv video player as a temporary workaround - Video Fix 2 - AnkiWeb (Video Fix 2) - but it didn’t go well, Anki can only be closed from the task manager and I couldn’t quickly find where is the problem, but it looks like the freezing issue is still there.
@kelciour Apologies for the naive questions, I have not been following closely. Is this issue limited to videos? Does it occur if a new mpv process is started each time? If yes to both those questions, perhaps we could work around the issue by loading a new mpv process when a video file is encountered, instead of using the slave mode machinery?
Thank you @dae. It looks like there isn’t much for me to do and it’s much better than I could come up with. Maybe a few modifications.
I changed is_audio_file by copy-pasting a line from editor.py, added config-dir to mpv and removed startupinfo because it causes the video window to be hidden and nowhere to be found on the latest mpv version. I considered using something like self.si=startupinfo() and startupinfo=self.si so it could be later overridden with None but wasn’t sure it’s necessary and would make sense.
I used make fix and the formatting is a bit different now.
My concern is how Mac will handle two mpv processes. Just in case, I sligntly changed the code to make it work on Mac and Linux as it used to be, i.e. just mpvManager for sound and video, and SimpleMpvPlayer will only be used on Windows and also set default_rank = 1 to make it to be chosen by Anki for video files.
It’s probably not possible to fork the same gist two times and this is a new one.