قالب وردپرس درنا توس
Home / Tips and Tricks / Using Siri to Play Spotify Music and Launch Playlists «iOS & iPhone :: Gadget Hacks

Using Siri to Play Spotify Music and Launch Playlists «iOS & iPhone :: Gadget Hacks



The Shortcuts app lets you create workflows to automate complex tasks, most of which can be activated with a simple, custom Siri command. For example, you can download videos from Instagram and open them in Chrome instead of Safari with just your voice. A more popular discovery is the use of Siri to control music streaming apps like Spotify and not just Apple Music.

The ability to use Siri to control Spotify music has been sought by Spotify users for some time. Now you can just open the Spotify app and pause and skip tracks after manually starting playback. Spotify knows this. However, it has no immediate plans to use SiriKit or the Shortcuts API to allow Siri to access the Spotify app. Instead, he spent more time using his own in-app tool Spotify Voice.

Spotify Voice is not as cool as Siri, so Reddit user fernix96 ( Lorenzo Ferrante ) created a custom shortcut for iOS 1

2 so you can use Siri to play a track or playlist on Spotify , He plans to make it into a full app called Shortify, so be on his guard. If you are in the Spotify team and are interested in setting up this shortcut on your iPhone, follow below. Just be warned, there is a lot to do, so getting to know the Shortcuts app is very helpful.

Before you proceed, make sure you have the latest version of Shortcuts, currently 2.1.2 also the latest version of iOS 12. Otherwise, you may receive the "Siri" response when trying to Spotify songs or playlists.

Step 1: Sign up for Spotify for Developers

This seems like a strange request, but to get Siri to control Spotify, you'll need a Spotify for Developer account . Developer accounts for Spotify are free, and you'll need it because in a later step, you'll need to connect the script to a few elements of your developer account for this to work.

In your favorite web browser, visit the developer .spotify.com / Dashboard on your iPhone, and then choose Sign In. You do not need to create a separate Dev account. Simply sign in with your existing free Spotify account or premium account. When you sign up, you accept the terms of service and your developer account is ready to use. (Note: If you have problems with the conditions in Safari, try another browser.)

Step 2: Create an App in Spotify for Developers

Go to Dashboard Dashboard if you are not there and tap "Client ID." create". Enter a name and description for the application that describes what you want it to do, and then select the Mobile App check box. Click Next, select "No" for commercial integration, and click "Submit" after agreeing to the three options.

Step 3: Install and Rename the Shortcut Link

Remove yourself from a Spotify for Developers account Then install Ferrante's shortcut named " Shortify2" (it's the second version of its workflow). You will not find this when you search or browse the Gallery in the Shortcuts app. Follow the link below to get it.

The link opens the info page of Shortify2 in Shortcuts. Tap "Get Shortcut" to install it. Next, go to the Library tab and touch either 3D Touch or tap the ellipses (•••) to open the Shortcut Editor.

In the top right corner, tap the Settings icon, then tap Name "and change it to" Shortify "to link the required script shortcut. Click Done when you're done.

Step 4: Install Scriptable

For This Complete Operation You may need a little JavaScript to connect the Shortcuts app to the app created in your Developer for Spotify account. So you need an app that lets you edit and save JavaScript, and Scriptable is a good choice.

Step 5: Create a New Script

That may sound intimidating if you do not know JavaScript, but you do not have to To worry. Ferrante has done all the legwork with his Shortify.js file, and you just have to visit the GitHub page and copy the entire script. For your convenience, you can also copy his script from below.

  // Base64 encoding your credentials
let clientID = & # 39;  & # 39;
let clientSecret = & # 39;  & # 39;
let cred = clientID + & # 39;: & # 39; + clientSecret
let credEncoded = Data.fromString (cred) .toBase64String ()
let auth = & # 39; Basic & # 39; + credencoded

// get tokens
let tokenURL = & # 39; https: //accounts.spotify.com/api/token'
var reqToken = new request (tokenURL)
reqToken.method = & # 39; POST & # 39;
reqToken.body = & # 39; grant_type = client_credentials & undefined = & # 39;
reqToken.headers = {
& # 39; Content-Type & # 39;: & # 39; application / x-www-form-urlencoded & # 39 ;,
& # 39; authorization & # 39 ;: auth
}

res res = waiting for reqToken.loadJSON ()
let token = res ['access_token']
let auth2 = & # 39; Bearer & # 39; + Tokens

// Params
var q = encodeURI (URLScheme.parameter (& # 39; query & # 39;))
var t = URLScheme.parameter (& # 39; type & # 39;

let endpoint = & # 39; https: //api.spotify.com/v1/search? q = & # 39; + q + & # 39; & type = & # 39; + t
let method = & # 39; GET & # 39;
leave headings = {
& # 39; Accept & # 39;: & # 39; application / json & # 39 ;,
& # 39; Content-Type & # 39;: & # 39; application / json & # 39 ;,
& # 39; Authorization & # 39 ;: auth2
}

// ask the request
leave req = new request (endpoint)
Method = Method
req.headers = header

// Get the track URL
let json = wait for req.loadJSON ()

var finalURL = & # 39; & # 39;
if (t == & # 39; track & # 39;) {
finalURL = json ['tracks']['items'][0]['external_urls']['spotify']
} else {
finalURL = json ['playlists']['items'][0]['external_urls']['spotify']
}

// open the track on Spotify
Safari.open (finalURL) 

If you copied the script to your clipboard, open the Scriptable app, tap the plus sign (+) to start a new script, and paste the text Shortify.js , Tap "Untitled Script" at the top and rename it "Shortify" to work with the Shortify shortcut of the past. Click on "Rename" to complete the process.

We are not finished yet, as we need to do this Change one few things in the script.

Step 6: Copy Information from Your Dev Dashboard

Go to developer.spotify.com/dashboard in your browser, search for the previously created Spotify app, and then tap and copy "client ID". You insert this ID into the shortify script that you created. You also need to copy the "Client Secret" identifier, but you can only copy one thing at a time.

Step 7: Save Script with Client ID and Client Secret

Go Return to the script Shortify in Scriptable and look for in the second line. Mark with the angle brackets and insert your "Client ID" above it. Next, go to step 6, tap Show Client Secret, and copy the numbers there. Return to Scriptable and paste it up . Tap Done on the top left to save it.

Step 8: Select either Title or Playlist in Shortcuts

Unfortunately, this shortcut we create can only listen to a song or a playlist. it can not listen to both. Edit the Shortify shortcut in the Shortcuts app again and enter either "Track" or "Playlist" in the second field Text of the workflow, just below the second Comment -Field. 19659002] If you have a premium Spotify account, you can select "Title" so that you can immediately play a specific title using the key combination. Playlist, which works for both premium and free Spotify accounts, simply opens the playlist in Spotify and does not play immediately. I have Premium, so I decided to search for titles, which is the default, because it extends my options in Spotify.

You can always go back and change "Title" for "Playlist" if you want tend to. You can also duplicate the entire shortcut with a different name and Siri command (the Siri command will be executed in the next step), so you can search for titles as well as playlists without having to edit the command.

Step 9: Add a Siri Command

Finally, you must add a Siri command for this to work. Touch the Settings icon while you are still editing the Shortify Shortcut Shortcut as you did when changing the shortcut name. Then tap "Add to Siri" and then "Type Phrase" to set the desired Siri command. You can go with anything, though something simple like "Search Spotify" should do the trick. When you're done, tap Done three times in a row to save and exit the workflow. You are done here!

Step 10: Using Siri to Play Music on Spotify

Now is the time to test all your hard work. Open Siri as you would normally do, be it with "Hey Siri" or the "Side" or "Home" shortcut, then say your Siri phrase from the previous step. Siri will ask you what you want to hear. The "dictation box" opens in shortcuts. Either say the name of a song or playlist, depending on which route you chose when setting up the link.

The shortcut is quickly redirected to the Shortify.js script that Safari uses to connect to your dev app and . URL scheme for opening Spotify and playing the desired song or playlist.

If you created the abbreviation Shortify here and you had problems or had other questions, you can insert a comment below. We will try to help you solve problems.

Do not miss: Calculate Faster Tips with the Shortcuts App on Your iPhone

Cover photo by Justin Meyers / Gadget Hacks; Screenshots of Nelson Aguilar / Gadget Hacks




Source link