Periodically Check for Videostream End of Video?

Hello!

I'm using Videostream in the Chrome browser to cast videos from my MacBook Pro to my Chromecast on my TV. Anytime a video ends, the Videostream UI hangs as if the video is still playing. In order to get it working again, I need to reload the tab in Chrome (⌘+R), which brings up a prompt, "Reload site? Changes you made may not be saved." And I need to hit tab then space (or return/enter, or just click the "Reload" button, since "Cancel" is selected by default).

Ideally, I would like to be able to run a Macro that loops every few seconds to check if the Videostream UI has reached the end of a video, and if so, then it automates sending the required keystrokes to reload the UI.

There's a progress bar in the UI that shows the current playback time/position of the video. I'm guessing there may be a better way of solving this than watching the UI/pixels to determine when a video has ended. But if not, maybe there's a way I could capture the current/elapsed time of the video playing from the UI as an image on each iteration of the loop, compare it to the image captured during the previous iteration, and if the image matches, it exits the loop and runs the macro to reload the UI.

I'm not sure if this is all possible with KM, and if so, which actions to use to do the capturing and comparison of a specific area of the UI (I can figure out the rest).

Also, if the screensaver starts on my MBP while casting, would this method still work, or would it only work if I prevented the screensaver from starting?

If anyone can help me figure this out, I'd seriously appreciate it.

Thank you!

I doubt there are any good ways to do this.

It is certainly possible to have a macro that runs and repeatedly looks at pixels on the screen. I suppose if everything else was kept fixed, then it could be possible you could do that, and detect the end of the video, and wait long enough to know it should be finished and then do the ⌘R and click the Reload button. It should work, though it would likely be pretty fragile.

Can you please lmk which actions I can use to check the pixels in an area of an app window, store that data, and then compare it to a new check of the same area later on?

You can use the PIXEL function to retrieve information about a specific pixel. That information can be stored in to a variable (eg with the Set Variable to Calculation action).

You can then use an If Then Else action and a Calculation condition to test for same or similar or different values of the PIXEL function later.

Hey Michelle,

I would probably go a different route...

First I'd try to find JavaScript elements in the video player window that I could test using an Execute a JavaScript in Front Browser action.

If I couldn't get the JS method working I'd try a Find Image on Screen action and run a loop looking for the end condition of the progress bar.

-Chris

1 Like