By Chad Wahlbrink @Chad2021-09-27 15:17:40.733Z
I have been working on this script to toggle between Tidal and Pro Tools playback. Currently, one of them needs to be playing in order to get it to work since I don't know how I would check if Tidal is playing.
In Tidal, the Playback menu switches between having "Play" and "Pause" as menu items. Is there an easy way to check if a menu item exists?
For instance, If "Play" exists in Tidal, I want to click it.
Chris Shaw @Chris_Shaw2021-09-27 17:29:54.351ZHere you go:
const tidalApp = sf.ui.app('com.tidal.desktop') // Determine if Play or Pause exists in Playback menu // This uses a ternary operator: If "Playback" exists then it will return "Play" otherwise it returns "Pause" var playOrPause = (tidalApp.getMenuItem("Playback", "Play").exists) ? "Play" : "Pause"; tidalApp.menuClick({ menuPath: ["Playback",playOrPause] });
Chris Shaw @Chris_Shaw2021-09-27 17:34:46.339ZThis assumes, of course, that Tidal is already open.
Chad Wahlbrink @Chad2021-09-27 18:54:33.054ZThis is great @Chris_Shaw ! Thanks for the help.
Here's what I have going now:
const tidalApp = sf.ui.app('com.tidal.desktop') // Determine if Play or Pause exists in Playback menu // This uses a ternary operator: If "Playback" exists then it will return "Play" otherwise it returns "Pause" // ↓ Thanks to Chris Shaw for this ↓ var playOrPause = (tidalApp.getMenuItem("Playback", "Play").exists) ? "Play" : "Pause"; if (sf.ui.proTools.isPlaying) { // Stop Pro Tools and Play Tidal sf.ui.proTools.mainWindow.transportViewCluster.transportButtons.stopButton.elementClick(); tidalApp.menuClick({ menuPath: ["Playback", "Play"] }) } else if (playOrPause == "Play") { // Play Tidal if neither is playing tidalApp.menuClick({ menuPath: ["Playback", "Play"] }) } else { // Pause Tidal and Play Pro Tools tidalApp.menuClick({ menuPath: ["Playback", "Pause"] }) sf.ui.proTools.mainWindow.transportViewCluster.transportButtons.playButton.elementClick(); }