Launch Multiple TVE Streams using AppleScript

I’ve been testing and working on how to view multiple channels from macOS desktop Safari web player mainly to watch news/sports channels while working from home due to Covid-19. Since Channels DVR enabled TVE functionality you’re able to open unlimited streams at the same time.

I’ve mapped a custom key on the Logitech keyboard to launch the process automatically. It opens up to six TVE streams on the left and right vertical monitors and set the middle monitor web page to the “On Now” guide so I can launch another channel via PIP.

You will need macOS, AppleScript, and BetterSnapTool if you want to snap & size the Safari windows automatically

BetterSnapTool

BetterSnapTool allows you to easily manage your window positions and sizes by either dragging them to one of the screen's corners or to the top, left or right side of the screen. This enables you to easily maximize your windows, position them side by side or even resize them to quarters of the screen. If you need even more than those standard snap areas, BetterSnapTool now allows you to create your own, custom snap areas anywhere on your display.

https://www.folivora.ai/bettersnaptool

Make sure to create a new snap area and Keyboard shortcuts to trigger the snap area.

AppleScript Editor

  1. Open AppleScript Editor and create a new document
  2. Copy & Paste below and Compile the script

In this example it will open four TVE streams and snap & size Safari windows to your monitor(s) automatically

-- Begin of AppleScript

-- Open Safari and and snap Safari Window center using Keypad #5 keyboard shortcut (CTRL+OPT+PAD5)

**tell** *application* "Safari" **to** **activate**

**tell** *application* "System Events"

**keystroke** "Keypad5" using { *control down* , *option down* }

**end** **tell**

-- Launch FS1 top left corner using Keypad #7 keyboard shortcut (CTRL+OPT+PAD7)

**delay** 2

**tell** *application* "Safari"

**make** new *document* with properties {URL:"http://192.168.7.220:8089/devices/ANY/channels/6197/hls/master.m3u8?"}

**activate**

**end** **tell**

**tell** *application* "System Events"

**keystroke** "Keypad7” using { *control down* , *option down* }

**end** **tell**

-- Launch ESPN top right corner using Keypad #9 keyboard shortcut (CTRL+OPT+PAD9)

**delay** 2

**tell** *application* "Safari"

**make** new *document* with properties {URL:"http://192.168.7.220:8089/devices/ANY/channels/6140/hls/master.m3u8?"}

**activate**

**end** **tell**

**tell** *application* "System Events"

**keystroke** "Keypad9” using { *control down* , *option down* }

**end** **tell**

-- Launch ESPN2 and snap window to the bottom left corner using Keypad #1 keyboard shortcut (CTRL+OPT+PAD1)

**delay** 2

**tell** *application* "Safari"

**make** new *document* with properties {URL:"http://192.168.7.220:8089/devices/ANY/channels/6141/hls/master.m3u8?"}

**activate**

**end** **tell**

**tell** *application* "System Events"

**keystroke** "Keypad1” using { *control down* , *option down* }

**end** **tell**

-- Launch NBCSN and snap window to the bottom right corner using Keypad #3 keyboard shortcut (CTRL+OPT+PAD3)

**delay** 2

**tell** *application* "Safari"

**make** new *document* with properties {URL:"http://192.168.7.220:8089/devices/ANY/channels/6161/hls/master.m3u8?"}

**activate**

**end** **tell**

**tell** *application* "System Events"

**keystroke** "Keypad3” using { *control down* , *option down* }

**end** **tell**

-- Set the system volume

**delay** 2

**set volume** output volume 5

-- End of AppleScript
  1. Save the script File Format as Application and name it “Watch TV” and place it in the Application Folder
  2. Make sure to enable Automation & Accessibility in Privacy tab

Logitech Keyboard (optional)

You can custom map a keyboard key to launch the AppleScript “Watch TV” app automatically.

3 Likes

Very nice love your setup. Thanks for sharing.

This is seriously great, thanks for sharing. Inspiring!

Just curious. How do you handle the audio, is there a way to quickly switch which feed you’re listening to?

At startup the System volume is set to 5 and all audio feeds are ON all Safari tabs at the same time. I couldn’t find a script to Mute All Tabs on startup so I click it manually to Mute All Tabs…then I click/unclick manually to Unmute the Tab I want to listen to, that’s how I switch between audio feed.

Hmm, I found this AppleScript solution from a few years ago, maybe it could help?
https://www.macscripter.net/viewtopic.php?id=45548

This tip is a game-changer for me, thanks again for sharing! I played around with it all day and learned a lot about AppleScript along the way.

On my 13" MacBook Pro currently I have two spaces, I can swipe back and forth between them with a three-finger swipe. Each has a 2x2 grid of live TV. So I'm streaming 8 channels at once! This is great. Prior to reading this thread I don't think I even dreamed this was possible. I'm working on my 27" iMac setup next, and will use an external display for something similar to yours.

One thing I discovered, that has made the display nicer and the overall interface a bit easier for me: the Channels URLs also play back in plain old QuickTime Player. No need to rely on Safari if you want to explore other options. Just choose File -> Open Location and paste the URL.

Here's the AppleScript I'm using:

set channel1 to "http://10.0.1.21:8089/devices/ANY/channels/6030/hls/master.m3u8?"
set channel2 to "http://10.0.1.21:8089/devices/ANY/channels/6050/hls/master.m3u8?"
set channel3 to "http://10.0.1.21:8089/devices/ANY/channels/5900/hls/master.m3u8?"
set channel4 to "http://10.0.1.21:8089/devices/ANY/channels/5907/hls/master.m3u8?"

tell application "QuickTime Player" to open URL channel1
tell application "QuickTime Player"
set bounds of front window to {0, 23, 720, 460}
end tell

tell application "QuickTime Player" to open URL channel2
tell application "QuickTime Player"
set bounds of front window to {720, 23, 1440, 460}
end tell

tell application "QuickTime Player" to open URL channel3
tell application "QuickTime Player"
set bounds of front window to {0, 460, 720, 900}
end tell

tell application "QuickTime Player" to open URL channel4
tell application "QuickTime Player"
set bounds of front window to {720, 460, 1440, 900}
end tell

Now I'm just trying to figure out how to script the muting all but one window. Option-Down Arrow mutes each window manually.

Helium works as a player too, and it offers some cool window translucency options, which I find perfect for live TV viewing while I am using that same laptop to work. Just thought I'd mention these options as they might inspire new ideas.

Thanks again.

P.S. I like what you've done with the matching vertical monitors there. What make/model are they?

3 Likes

The client is running on Mac Pro (Late 2013) and Channels DVR is running on Mac mini (Late 2012)

Center Monitor: LG 27" 4K UHD IPS LED Monitor - 27UD58B
Left/Right Monitors: LG 24" 4K UHD IPS LED Monitor - 24UD58B

Use the key codes with modifiers to simulate option arrow key down sequence.

This works well even when AirPlayed to my AppleTV for display on my big TV screen.

Pretty incredible, all things considered.

1 Like

Whoa! How did you do that? Airplay your second monitor to appletv or some other method?

In my case, I am simply AirPlaying from a MacBook Pro to my AppleTV. No second monitor is involved. I can mirror the built-in display, or even set up the AppleTV as a separate (wireless) display so I can still use the laptop screen while the Channels streams are in a grid on the TV.

CleanShot 2020-08-12 at 06.40.29

Let’s try to automate macOS AirPlay to ATV from iPhone:


1 Like

I’m assuming you have no monthly data cap with your internet provider? (I don’t, at least for now, with Spectrum.) But I do have to wonder just how much bandwidth a setup like this consumes monthly. Six concurrent video streams, quite a few hours per day, any idea what that adds up to? I’d be curious if your ISP tracked this. Spectrum doesn’t show me any stats.

I have CenturyLink Gigabit Fiber residential plan and there are no data cap at the moment. I stream all day from 8-5pm from my desk while working with no issue except some stream get timeout.

At peak time there are about 10+ TVE concurrent video streams going on the same time from different room and app like QuadStream on ATV, Hulu, Netflix, ESPN MultiCast, and Disney+ for the kids. CenturyLink doesn’t show me any stats either. I’m pretty sure they track the data usage and where the streams are coming from. If they start blocking then I might consider moving to the business plan.

OK wow, another game-changer! I just tried this app with my top 4 Channels URLs and it’s working well.

The interface needs a little work, lol. ESPN’s MultiCast implementation is much more intuitive. But in its current form, this is even better than AirPlaying the 2x2 grid from my laptop! 4 live channels at once on my AppleTV, this is great. Looks like the developer isn’t really working on it though. Hopefully it inspires the Channels devs to incorporate similar functionality into the actual Channels DVR app!

In any case, thanks for mentioning it. Super cool.

P.S. just found your older thread about it. As you can tell, I am a new and enthusiastic Channels user :slight_smile:
QuadStream + Channels DVR