A method for playing video clips in a floating window?

As part of a recent presentation that I gave, I had a palette whereby I could press a button and an audio clip would play (standard KM 'Play Sound' macro), combined with a 'Display Text (large)' macro that was used for purposes of showing a caption. Works great!

But I have some ideas for a talk where it will involve audience participation and I would like to be able to trigger video clips (which would also have the associated caption). There is no 'Play video' macro, though. So, is there a way that a combination of macros could achieve this?

  • I might want to set some sizing
  • I'd want the video clip to disappear once played
  • I don't want to have any play/pause/transport controls visible
  • It should overlay anything currently on screen (which may be a Keynote or PPT slide)

Is this something that may be possible with KM, do you think? Or should I be looking elsewhere for this?

You might be able to do it with a custom HTML prompt and some HTML5 video handling code. KM can make such windows floating as well (via the gear icon menu), so it'd appear in front of everything.

Here's a very rough proof of concept:

Download Macro(s): Video Player.kmmacros (1.9 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.4.1
  • Keyboard Maestro v11.0.2

You could/should do a lot more with that, though—the position and sizing, for instance. But hopefully it's enough to get you started.

-rob.

1 Like

Would it suit your needs to call an external video player? I think that you may well be able achieve all you need to by using KM to control the free video player IINA.

This can be done via IINA's menu, so you could use a Select or show a menu item action.

Use the same kind of action to close the window.

:white_check_mark:

"Float on top" is available in the menu.

1 Like

Thanks for the suggestions - I'll give both a try and see which one feels right. But this is really useful info :+1:

I have given this a go, and I need to be able to close the floating window after a certain duration. I found this on the forum which seemed to be the answer:

However, this is not working for me.

I amended your example to this:

And here is the macro that should close the window:

image

It's not closing the prompt window, and when I manually intervene, then I get the error message:

2024-04-18 11:06:42 No matching Custom HTML Prompt windows found. Macro “Video Player” cancelled (while executing Execute a JavaScript in Custom Prompt with ID “KMVideoPlayer”).

Here's the whole macro as an image:

image

Any thoughts on what I've missed here?

I wanted to use this IINA player, but I found one particular issue - it animates to the video size in a rather annoying way. I want it to just open at the default size for the video, but I could not work out the various preferences to stop it behaving as it is. Any idea how I can stop that animation?

From the next post in the thread you linked, the actual command is

window.KeyboardMaestro.Cancel();

image

All I could find was that if you turn "IINA > Settings > UI > Resize the window to fit video size" to "Disabled", the amount of animation is reduced.