# Action to control Spotify only

**URL:** <https://community.folivora.ai/t/action-to-control-spotify-only/7222>\
**Category:** Configuration Help & General Discussion\
**Created:** [March 8, 2019, 3:18am UTC](https://community.folivora.ai/t/action-to-control-spotify-only/7222 "2019-03-08T03:18:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![yuuiko](https://community.folivora.ai/user_avatar/community.folivora.ai/yuuiko/32/31891_2.png) [@yuuiko](https://community.folivora.ai/u/yuuiko)\
**Post date:** [March 10, 2019, 11:10pm UTC](https://community.folivora.ai/t/action-to-control-spotify-only/7222/2 "2019-03-10T23:10:14Z")

</div>

You can do this with an applescript action!

The code is easy, something like:

```auto
tell application "Spotify" to playpause
```

The code I use is a bit more complicated. It won't open spotify randomly and it also stabilises the action so that if an error happens it'll be fine.

```auto
--control Spotify playback directly and not something else

if application "Spotify" is running then
	tell application "Spotify"
		try
			playpause
		on error
			return "-"
		end try
	end tell
else
	return "-"
end if
```

This code is from my preset [AquaTouch](https://community.folivora.ai/t/aquatouch-functionally-minimal-clean-and-proactive-preset-version-2-1-updated-24-september-2018/1704), which has app-specific play/pause buttons for iTunes, Spotify and YouTube. [Check it out](https://community.folivora.ai/t/aquatouch-functionally-minimal-clean-and-proactive-preset-version-2-1-updated-24-september-2018/1704)!

---

_[View the full topic](https://community.folivora.ai/t/action-to-control-spotify-only/7222)._
