The issue I'd like to solve is that VLC opens in Always On Top mode, despite this being disabled in VLC Preferences. Any help appreciated.
VLC behaves normally if you open the file manually (i.e. not via Terminal), so I wonder if there's a way to pause until the video is partially downloaded and then open it via KM. Perhaps there's a way to keep checking the size of the folder (/tmp/torrent-stream) at intervals, and then open it in VLC once the size exceeds something sensible, like 50mb?
EDIT: It now waits for the folder size to indicate that enough has downloaded for the video to play and then opens it in VLC directly. I've updated the above macro accordingly. Big thanks to @Sleepy for helping with that!
Here's a companion macro that will ask you whether you want to trash the temporary files when you quit VLC, if any exist, then force-quit Terminal:
That might work, but you didn't say what happens when you use a different action to launch VLC, like the two options I mentioned above. That might be easier than calculating the size of a folder.
Of course, I can manually open the file once it's downloaded enough to play. The thing is, if you try to open the file in VLC (as part of the macro) before it's sufficiently downloaded, it fails and returns to the playlist window. That's why I figured pausing until the folder was over a certain size (and then opening via KM) might be one way to ensure it would play properly. I've tried a simple 10 second pause, but this doesn't always work, depending on the download speed, which is determined by the number of peers sharing the file, and their respective connection speeds.
Ok I feel like I'm close, but maybe I've misunderstood how to compare a variable to a number, because it always shows as "currently false", even when the file is much bigger. I've checked that the script is outputting the correct file size. Any suggestions?
I will help you with the folder size calculation approach, even though I think my other approach is simpler and I think we still haven't communicated our intentions correctly regarding it. But now we move on to the folder size approach, which is also valid.
I see you are using AppleScript to solve that. I think I know a much easier way. I'm not going to try to validate your AppleScript. Your calculation looks fine to me, so I'm not going to troubleshoot the AppleScript when I think there's a much easier solution. Let me work on the alternate solution instead. Be back soon.
Thankyou! In my initial post, I did say that VLC works normally if it's not launched from Terminal. Sorry if I waffled so much that it became unclear. I'm a bit hungover today so not firing on all cylinders!
For what it's worth, the script is working fine, as you can see:
I just tested by adding a random video file to the folder (a jazz guitar lesson ) and it's getting the size just fine.