Looking for a Fast Forward and Rewind Macro

I would like to control media in Google Chrome using shortcuts, more specifically I would like to be able to fast forward/rewind 3 seconds using a keyboard shortcut that works globally no matter what app is in front. I'm using Mac which lets me control start/stop globally with a hotkey but I have been unable to find a solution for fast forward/rewind.

To be even more specific. I would like to be able to rewind YouTube videos and udemy videos using just a hotkey while I'm working in an IDE. So let's say I'm writing in an IDE while listening to a video about programming running on udemy, at this point I can use a hotkey to pause and start the video even though I am working in the IDE. But I would also like to rewind 3 seconds with just a hotkey if there was something I need to hear again, but I don't want to have to manually switch to the browser and then use a hotkey to rewind the video.

I want to do be able to do it with just one action.

Here's an example with YouTube. It brings the browser (in my case, Brave) to the front, rewinds by simulating the โ† key, and then brings the app you started in back to the front.

Rewind YouTube.kmmacros (21 KB)

Macro screenshot

Thanks for the quick reply. For some reason it didn't work for me when I tried using it in chrome, however I made another version that does the same thing just using cmnd+tab and it worked fine on both udemy and youtube.

Rewind YouTube.kmmacros (2.8 KB)

However both these solutions are a bit flimsy and there are situations where they wont work, like if you have a second browser window open it will sometimes mess up the macro.

Are there any other solutions or ideas?

Okay let's go a bit deeper. Change the name of the media-playing website in the green action and change the red actions according to your browser of choice. Three of the four red actions just require you to choose a different browser from the drop-down; in the AppleScript, you'll want to change:

tell application "Brave Browser"
to, for example
tell application "Google Chrome"

Rewind YouTube.kmmacros (26 KB)

Macro screenshot

Of course, if you have multiple YouTube tabs, this may not work as expected. We could have a go at identifying the tab that's currently playing media... but for now, let's see if this works for you in principle.

With reference to multiple tabs whose titles include the same name... If you're using a Chrome-based browser, we might be able to incorporate this into the macro:

I don't use a macro to do this, but another app called Movist Pro. It does exactly what you want; control a video, YouTube or otherwise, in the background, using the built-in media keys to fast forward and rewind. You can even customize the seek speed.

3 Likes

I don't know if this works in Chrome, as I am a Safari fan.

But in Safari, this works well:

Let me know if you want me to upload the two macros for skip back and skip forward.

1 Like

Safari's fine, but doesn't seem to want to work for Brave Browser; can't speak for any others.

1 Like

It occurred to me that the last part of my macro works if you leave the YouTube video as the active tab in the web browser.

The web browser can be hidden, so it fits that criteria.

The letter "J" skips back, and the letter "L" skips forward in YouTube.

Tested in Brave and it works. Will most likely work in Chrome.

3 Likes

I've never really made use of the send to feature and this makes me want to look into it. :+1:t3:

2 Likes

Nyet. But this will:

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2022/11/18 21:33
# dMod: 2022/11/19 00:12
# Appl: Google Chrome, System Events
# Task: Bring a Singular YouTube Window to the Front.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @System_Events, @YouTube, @Window, @Front
--------------------------------------------------------

set theURL to "https://www.youtube.com/"

tell application "Google Chrome"
   set winList to windows whose active tab's URL is theURL
   if length of winList = 1 then
      set youtubeWindow to item 1 of winList
      if index of youtubeWindow โ‰  1 then
         set index of youtubeWindow to 1
         raiseWindow() of me
      end if
   else
      beep
      error "Too many or too few windows were found!"
   end if
end tell

--------------------------------------------------------
--ยป HANDLERS
--------------------------------------------------------
on raiseWindow()
   tell application "System Events"
      tell (first application process whose frontmost is true)
         tell front window
            perform action "AXRaise"
         end tell
      end tell
   end tell
end raiseWindow
--------------------------------------------------------
1 Like

Nicely done @ccstone!

1 Like

Some improvements I can imagine to my macro suggestion above are:

  • Make tab with desired URL frontmost without needing to switch to the browser, so keystrokes can be sent to it discreetly. Is that what your script does, @ccstone? I haven't had a chance to try it yet.

  • Make tab currently playing audio the frontmost tab, rather than set by URL, in case there are multiple tabs off the same URL family.

You can't โ€“ unless the window containing the YouTube tab is frontmost.

And this cannot be done reliably when Google Chrome is hidden in the background โ€“ the app has to be visible if not the frontmost app.

So this won't necessarily be completely discreet.