Intro
When going motorcycling, or just generally commuting by motorcycle, I often want to have some tunes playing in the helmet.
Since I have a Cardo Scala G4 bluetooth intercom installed on my helmets, it's a given to use that to play Spotify while riding.
To be able to do this, is actually why I got Tasker in the first place. I have since branched out a lot and automated a lot of stuff, but that's another article coming.
My base for this Tasker project is outlined at http://richardpeacock.com/blog/2015/09/make-spotify-start-playing-over-bluetooth-when-you-get-your-car-or-any-other-bt-device-.
After having followed Mr Peacock's excellent guide I was quite happy for a long time, until something in Spotify or Android changed, and the music didn't auto-play on BT-connection anymore.
Further trouble-shooting was needed, and I did find a solution. These tweaks are noted inline in the Guide-part.
Tasker strictly speaking does not need root access. If you however want to delve deeper with automation and Tasker on Android devices, you may want to investigate rooting!
Note! This guide uses a Cardo intercom unit, but any bluetooth enabled intercom should work. This also includes bluetooth-enabled car media systems.
Assumptions
I'm going to assume the reader is fairly accustomed to working with Tasker.
If you, the reader, runs into any problems, please search the 'net for solutions or just ask below in the comments field. I'll do what I can to help.
Hard- and software list
For reference. This is my setup.
Oneplus One ("OPO")
https://www.gsmarena.com/oneplus_one-6327.php
OPO is custom-flashed with LineageOS 14.1
https://en.wikipedia.org/wiki/LineageOS
LineageOS 14.1 is based on Android 7.1.2, aka Nougat
https://en.wikipedia.org/wiki/Android_Nougat
Rooted and using SuperSU.
http://www.supersu.com/
TWRP v3 recovery installed.
https://twrp.me/
Got a new phone from work again, replacing the previous. This time it was a OnePlus 8 Pro with 8 GB internal RAM and 128 GB externally.
Importing the Tasker tasks, profiles etc to the new phone was a breeze and all tasks and profiles work as is on the Oneplus.
Samsung Galaxy S9 64 GB
https://www.gsmarena.com/samsung_galaxy_s9-8966.php
Android 9 Pie
https://en.wikipedia.org/wiki/Android_Pie
OnePlus 8 Pro 128 GB/8 GB
https://www.gsmarena.com/oneplus_8_pro-9919.php
Oneplus 11 128 GB/8 GB
https://www.gsmarena.com/oneplus_11-11893.php
Android 11
https://en.wikipedia.org/wiki/Android_11
Android 14
https://en.wikipedia.org/wiki/Android_14
OxygenOS 14
https://en.wikipedia.org/wiki/OxygenOS
Latest Spotify app installed.
https://www.spotify.com/
https://play.google.com/store/apps/details?id=com.spotify.music
Latest Tasker app installed. Please buy it and support the dev! The app is well worth it.
https://tasker.joaoapps.com/
https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en
Cardo Scala G4 and G9 Teamset
https://www.cardosystems.com/support/g4/
https://cardosystems.com/pages/support/g9
Guide
In which we will make the android device connect to the intercom over bluetooth, when the android device detects the intercom is switched on, and then starts the Spotify app.
Make your mobile device and the intercom talk to each other
Pair your mobile phone and Cardo unit and make it works properly.
Instructions for pairing a Cardo Scala G4/G9 Teamset unit is available on page 9 at https://www.cardosystems.com/wp-content/uploads/guides/manual/en/g4.pdf.
Create the Tasker profile
In which we create the main task.
- In Profiles tab, press +.
- Select State.
- Select Net.
- Select BT Connected.
- Press the magnifier icon next to Name and select which BT-unit you want to trigger the connection with.
- Press the magnifier icon next to Address and select the same device as above.
- Back out to the Profiles tab and confirm the creation of the new task. Name it if you want to, preferrably something meaningful like "BT Connected Start Play Spotify" or some such.
Launching Spotify
In which we edit the previously created task to launch Spotify.
- In Profiles tab, press +.
- Select App.
- Select Launch app.
- Select Spotify.
- Back out to the Profiles tab.
Pause a short while Spotify gets its things together
In which we add a wait-timer.
- In Profiles tab, press +.
- Select Task category.
- Select Wait.
- Set Seconds to ten. The referenced guides show five, but ten is what my OPO needed to fire things up.
- Back out to the Profiles tab.
Adjust media volume
In which we max out the mobile device media volume in order to not cap the intercom volume.
Note! Remember that loud sounds may damage your hearing irrevocably!
- In Profiles tab, press +.
- Select Audio.
- Select Media Volume.
- Select Level to set the volume to max. Use your discretion here. My OPO is maxed out at "14".
- Back out to the Profiles tab.
Making stuff happen!
In which we add the automagics to the task, in other words "press play already!".
- In Profiles tab, press +.
- Press System.
- Press Send Intent.
- Edit the following fields. Be sure to write exactly as stated below. No spaces, upper case etc!
- Action: com.spotify.mobile.android.ui.widget.PLAY
- Cat: None
- Package: com.spotify.music
- Target: Broadcast Receiver
- Back out to the Profiles tab.
- Press the check-mark on the main page to commit the changes.
- You're done.
Testing
Turn off your Cardo, then turn it on again.
It should connect to your mobile device over bluetooth and launch the Spotify app after the set pause.
Or not, as in my case...
Which then leads us to the next chapter - troubleshooting the infernal device.
Troubleshooting why Spotify doesn't start playing
So, Spotify launched as expected but nothing happened afterwards. It just sits there. Woe of woes!
Step 1
Long-press the Cardo unit's A-button (front, side) to toggle the play/pause function. You should hear a too-whit! If you hear a too-whuut! it's now paused.
Long-press it again to make sure no funny business is going on.
Still nothing? Proceed to step 2.
Step 2
Search the web for the problem. For the honoured reader's convenience, here is a possible solution.
This particular solution will sadly always skip forward one track, but it does work. Call it a workaround!
Go back to the task called Making stuff happen. Edit and replace PLAY with NEXT instead.
Note! Only change PLAY with NEXT, leave everything else unchanged.
- In Profiles tab, press the task that launches Spotify.
- Edit the following field
- Edit Action: com.spotify.mobile.android.ui.widget.PLAY
- Replace with Action: com.spotify.mobile.android.ui.widget.NEXT
- Back out to the Profiles tab.
- Press the check-mark on the main page to commit the changes.
Still nothing? Proceed to step 3.
Step 3
This is a bonus step. I got my task working in step 2!
Search the web some more for the problem. For the honoured reader's convenience, here is a another possible solution.
Replace the above play action in step 2 with this.
- In Profiles tab, press +.
- Select Media.
- Select Media Control.
- Select Play (simulated only).
- Set App as Spotify.
- Back out to the Profiles tab.
- Press the check-mark on the main page to commit the changes.
Turn off your Cardo yet again and then on again to see if Spotify starts playing now.
I actually did try this last solution too, just for fun. It started playing the last media file played by the default Android media player, in my case the ring tone.
Kinda' worked though, just not quite as expected; YMMV.
Conclusion
If everything worked out, you're now ready to go out and try it for real.
Keep riding, keep rocking!
Sources
https://androidcommunity.com/tasker-going-deeper-into-automation-with-root-access-20170531/
https://androidtrix.wordpress.com/2013/11/05/tasker-spotify-plug-load-and-play/
https://stackoverflow.com/questions/43129548/pressing-play-on-spotify-through-an-intent
https://forum.joaoapps.com/index.php?threads/spotify-api-play-pause.18649/
https://en.wikipedia.org/wiki/Noise-induced_hearing_loss