I want to play an MP4 file using the VLC app. Let's call the file “video.mp4”.
I can do this by using the open file name action specifying”video.mp4” and the application to be VLC
I want to play the mp4 from the beginning.
If I have not played the file before then it works fine.
However, if I have PARTLY played the file before, VLC pops up a dialogue saying
A: do I want to restart from the beginning or
B: Continue from where I left off?
I want to restart, so I could use the VLC jump to 0.00 position action.
What is the best way of handling this “optional” dialogue?
I ask this as there must be a generic good practice of handling "optional" dialogue.
However, while this is fine if you never want to resume playback, but if you do you might need to resort to AppleScript (since VLC has good AS support) or even run VLC from a shell script using command-line parameters - but I haven't investigated those options...
@tiffle's got the better answers, but you could also play off the fact that VLC's dialog is actually a window -- count the number of windows before you open the video, open the video, pause until the WINDOWCOUNT() is greater than (previous window count + 1) then click the found image of the restart button.
This works because the pause condition has a 2 second, abort without notification, timeout so that if the dialog doesn't appear the macro will quickly cancel itself:
The general pattern would be "see if a dialog shows up then deal with it" -- but is so broad as to be practically useless Everything else is situational -- if it's a "proper" Mac app with "proper" Mac dialogs you could pause until a button exists (again with an appropriate timeout), you could hard-code a pause then test to see if there's a dialog, if you don't know when the "optional" dialog might appear and want your original macro to continue you could spawn an asynchronous background macro that used button- or image-detection... And I see @noisneil's just suggested a completely separate macro, triggered by front window changes.
Thanks to everyone who has contributed.
I have now set the option to ALWAYS continue playback, so the dialogue never comes up (Thx Tiffle)
I will then use Jump to position zero to restart the playback.