[Tasker Script] Redirect ringer to headphones

agentx3r

Member
Nov 25, 2011
23
13
0
So I use headphones a lot and I've gotten really sick of the way skyrocket handles the ringer while I've got headphones plugged in. In silent mode, nothing is played at all, and in ringer mode, the ringtone plays from the internal speaker instead of the headphones.

So I wrote up a simple Tasker script that forces the phone to play ringtone/notification sound from headphones if they're plugged in, and the speaker if headphones are not plugged in. This also pauses the music that's currently playing by spoofing a headset-pause button press.

Notes: %SANE is whatever you decide is a good volume for ringtone playing through headphones, don't want anyone to go deaf. Mine is usually set to 4.

Set the system ringtone/notification to 'silent' or 'none', and put your desired sounds into the ringtones folder (Ringtone.mp3 and Notification.mp3 or w/e). Tasker catches the phone call, and plays them like media files, forcing them to go through headphones if available.

Keeps track if headphones plugged in/out
Code:
Profile: Headphones In (3)
State: Headset Plugged [ Type:Any ]
Enter: Publish HP (4)
A1: Variable Set [Name:%HEADPHONES To:True Do Maths:Off Append:Off] 
A2: Variable Set [Name:%VOLRSAVE To:%VOLR Do Maths:Off Append:Off] 
A3: Ringer Volume [Level:0 Display:Off Sound:Off] 
A4: Silent Mode [Mode:Vibrate] 
A5: Profile Status [Name:Catch VolM 0 Set:On] 
A6: Profile Status [Name:Catch VolR 0 Set:On]

Exit: Unpublish HP (6)
A1: Variable Set [Name:%HEADPHONES To:False Do Maths:Off Append:Off] 
A2: Ringer Volume [Level:%VOLRSAVE Display:Off Sound:Off] 
A3: Profile Status [Name:Catch VolM 0 Set:Off] 
A4: Profile Status [Name:Catch VolR 0 Set:Off]
Catches phone call
Code:
Profile: Incoming Phone Call (14)
State: Incoming Call [ Caller:* ]
Enter: Ring (15)
A1: Variable Set [Name:%VOLMSAVE To:%VOLM Do Maths:Off Append:Off] 
A2: Media Control [Cmd:Pause Simulate Media Button:On] 
A3: Media Volume [Level:%SANE Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ True ]
A4: Media Volume [Level:%VOLR Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ False ]
A5: Music Play [File:Ringtones/Ringtone.m4a Start:30 Loop:Off]

Exit: Kill Ringer (17)
A1: Music Stop [Clear Dir:Off] 
A2: Media Volume [Level:%VOLMSAVE Display:Off Sound:Off] 
A3: Media Control [Cmd:Toggle Pause Simulate Media Button:On] Media Control [ %HEADPHONES ~ True ]
Catches SMS
Code:
Profile: SMS (19)
Event: Received Text [ Type:Any Sender:* Content:* ]
Enter: Beep (20)
A1: Variable Set [Name:%VOLMSAVE To:%VOLM Do Maths:Off Append:Off] 
A2: Media Control [Cmd:Pause Simulate Media Button:On] 
A3: Media Volume [Level:%SANE Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ True ]
A4: Media Volume [Level:%VOLR Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ False ]
A5: Music Play [File:Ringtones/Notification.mp3 Start:0 Loop:Off] 
A6: Wait [MS:0 Seconds:3 Minutes:0 Hours:0 Days:0] 
A7: Music Stop [Clear Dir:Off] 
A8: Media Volume [Level:%VOLMSAVE Display:Off Sound:Off] 
A9: Media Control [Cmd:Toggle Pause Simulate Media Button:On] Media Control [ %HEADPHONES ~ True ]
Works well on my phone. Automatically resumes music after ringer/sms if headphones are plugged in.

Comments, questions, suggestions welcome! Lemme know if this works on your phones.
 
Last edited:

agentx3r

Member
Nov 25, 2011
23
13
0
Last thing that really pissed me off after switching from iPhone to Android and losing my Activator shortcuts, being able to pause/switch songs while screen is off.

Basically, while headphones are plugged in, turn volume all the way down to pause/unpause, or turn it all the way down and then back up to skip to the next song! Requires the headphone profile from above post.

Code: When music is not playing, turn ringer volume all the way down until phone vibrates, and music will start playing. Immediately after vibration, increase the volume and then music will play the NEXT track instead of just resuming.
Code:
Profile: Catch VolR 0 (23)
Priority: 5 CoolDown: 3
Event: Variable Set [ Variable:%VOLR Value:* ]
Enter: Unpause, Maybe Skip (24)
A1: Media Control [Cmd:Toggle Pause Simulate Media Button:On] 
A2: Wait [MS:0 Seconds:1 Minutes:0 Hours:0 Days:0] 
A3: Variable Set [Name:%SKIP To:M Do Maths:Off Append:Off] Variable Set [ %VOLR > 0 ]
A4: Vibrate [Time:200] Vibrate [ %SKIP Is Set ]
A5: Media Control [Cmd:Next Simulate Media Button:On] Media Control [ %SKIP Is Set ]
A6: Variable Clear [Name:%SKIP Pattern Matching:Off] 
A7: Media Volume [Level:%SANE Display:Off Sound:Off] 
A8: Ringer Volume [Level:0 Display:Off Sound:Off] 
A9: Wait [MS:0 Seconds:3 Minutes:0 Hours:0 Days:0] 
A10: Variable Set [Name:%SANE To:%VOLM Do Maths:Off Append:Off] 
A11: Flash [Text:Default Volume: %SANE Long:Off]
Code: When music is playing, turn the media volume all the way down until phone vibrates, and music will pause. Immediately after vibration, increase the volume and then music will play the NEXT track instead of just pausing.
Code:
Profile: Catch VolM 0 (25)
Event: Variable Set [ Variable:%VOLM Value:0 ]
Enter: Pause Or Skip (26)
A1: Vibrate [Time:200] 
A2: Wait [MS:0 Seconds:1 Minutes:0 Hours:0 Days:0] 
A3: Variable Set [Name:%SKIP To:T Do Maths:Off Append:Off] Variable Set [ %VOLM > 0 ]
A4: Media Control [Cmd:Toggle Pause Simulate Media Button:On] Media Control [ %SKIP ! Set ]
A5: Media Control [Cmd:Next Simulate Media Button:On] Media Control [ %SKIP Is Set ]
A6: Media Volume [Level:%SANE Display:Off Sound:Off] Media Volume [ %SKIP Is Set ]
A7: Variable Clear [Name:%SKIP Pattern Matching:Off]
 
Last edited:
  • Like
Reactions: JdgM3NT4L and jmhb

kcajith

Senior Member
Apr 13, 2012
132
12
0
Can u let me know how do i use this script..iam clue less!..your help is appreciated.
thx
ajith


So I use headphones a lot and I've gotten really sick of the way skyrocket handles the ringer while I've got headphones plugged in. In silent mode, nothing is played at all, and in ringer mode, the ringtone plays from the internal speaker instead of the headphones.

So I wrote up a simple Tasker script that forces the phone to play ringtone/notification sound from headphones if they're plugged in, and the speaker if headphones are not plugged in. This also pauses the music that's currently playing by spoofing a headset-pause button press.

Notes: %SANE is whatever you decide is a good volume for ringtone playing through headphones, don't want anyone to go deaf. Mine is usually set to 4.

Set the system ringtone/notification to 'silent' or 'none', and put your desired sounds into the ringtones folder (Ringtone.mp3 and Notification.mp3 or w/e). Tasker catches the phone call, and plays them like media files, forcing them to go through headphones if available.

Keeps track if headphones plugged in/out
Code:
Profile: Headphones In (3)
State: Headset Plugged [ Type:Any ]
Enter: Publish HP (4)
A1: Variable Set [Name:%HEADPHONES To:True Do Maths:Off Append:Off] 
A2: Variable Set [Name:%VOLRSAVE To:%VOLR Do Maths:Off Append:Off] 
A3: Ringer Volume [Level:0 Display:Off Sound:Off] 
A4: Silent Mode [Mode:Vibrate] 
A5: Profile Status [Name:Catch VolM 0 Set:On] 
A6: Profile Status [Name:Catch VolR 0 Set:On]

Exit: Unpublish HP (6)
A1: Variable Set [Name:%HEADPHONES To:False Do Maths:Off Append:Off] 
A2: Ringer Volume [Level:%VOLRSAVE Display:Off Sound:Off] 
A3: Profile Status [Name:Catch VolM 0 Set:Off] 
A4: Profile Status [Name:Catch VolR 0 Set:Off]
Catches phone call
Code:
Profile: Incoming Phone Call (14)
State: Incoming Call [ Caller:* ]
Enter: Ring (15)
A1: Variable Set [Name:%VOLMSAVE To:%VOLM Do Maths:Off Append:Off] 
A2: Media Control [Cmd:Pause Simulate Media Button:On] 
A3: Media Volume [Level:%SANE Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ True ]
A4: Media Volume [Level:%VOLR Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ False ]
A5: Music Play [File:Ringtones/Ringtone.m4a Start:30 Loop:Off]

Exit: Kill Ringer (17)
A1: Music Stop [Clear Dir:Off] 
A2: Media Volume [Level:%VOLMSAVE Display:Off Sound:Off] 
A3: Media Control [Cmd:Toggle Pause Simulate Media Button:On] Media Control [ %HEADPHONES ~ True ]
Catches SMS
Code:
Profile: SMS (19)
Event: Received Text [ Type:Any Sender:* Content:* ]
Enter: Beep (20)
A1: Variable Set [Name:%VOLMSAVE To:%VOLM Do Maths:Off Append:Off] 
A2: Media Control [Cmd:Pause Simulate Media Button:On] 
A3: Media Volume [Level:%SANE Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ True ]
A4: Media Volume [Level:%VOLR Display:Off Sound:Off] Media Volume [ %HEADPHONES ~ False ]
A5: Music Play [File:Ringtones/Notification.mp3 Start:0 Loop:Off] 
A6: Wait [MS:0 Seconds:3 Minutes:0 Hours:0 Days:0] 
A7: Music Stop [Clear Dir:Off] 
A8: Media Volume [Level:%VOLMSAVE Display:Off Sound:Off] 
A9: Media Control [Cmd:Toggle Pause Simulate Media Button:On] Media Control [ %HEADPHONES ~ True ]
Works well on my phone. Automatically resumes music after ringer/sms if headphones are plugged in.

Comments, questions, suggestions welcome! Lemme know if this works on your phones.
 

jmhb

New member
May 29, 2012
1
0
0
small step

Thanks for posting this! I just installed tasker and wrote up your code, so I haven't had a chance to test it out yet.
For anyone else who's installing this app an immediately trying to add these profiles, you'll need to get out of "beginner mode" first. On the application's home-screen, go to menu > preferences and uncheck "Beginner Mode".

This may be a simple thing, but it initially caused me some confusion.
 

marianoasis

Senior Member
Feb 20, 2013
953
78
58
buenos aires
HELP!!

so i use headphones a lot and i've gotten really sick of the way skyrocket handles the ringer while i've got headphones plugged in. In silent mode, nothing is played at all, and in ringer mode, the ringtone plays from the internal speaker instead of the headphones.

So i wrote up a simple tasker script that forces the phone to play ringtone/notification sound from headphones if they're plugged in, and the speaker if headphones are not plugged in. This also pauses the music that's currently playing by spoofing a headset-pause button press.

Notes: %sane is whatever you decide is a good volume for ringtone playing through headphones, don't want anyone to go deaf. Mine is usually set to 4.

Set the system ringtone/notification to 'silent' or 'none', and put your desired sounds into the ringtones folder (ringtone.mp3 and notification.mp3 or w/e). Tasker catches the phone call, and plays them like media files, forcing them to go through headphones if available.

Keeps track if headphones plugged in/out
Code:
profile: Headphones in (3)
state: Headset plugged [ type:any ]
enter: Publish hp (4)
a1: Variable set [name:%headphones to:true do maths:eek:ff append:eek:ff] 
a2: Variable set [name:%volrsave to:%volr do maths:eek:ff append:eek:ff] 
a3: Ringer volume [level:0 display:eek:ff sound:eek:ff] 
a4: Silent mode [mode:vibrate] 
a5: Profile status [name:catch volm 0 set:eek:n] 
a6: Profile status [name:catch volr 0 set:eek:n]

exit: Unpublish hp (6)
a1: Variable set [name:%headphones to:false do maths:eek:ff append:eek:ff] 
a2: Ringer volume [level:%volrsave display:eek:ff sound:eek:ff] 
a3: Profile status [name:catch volm 0 set:eek:ff] 
a4: Profile status [name:catch volr 0 set:eek:ff]
catches phone call
Code:
profile: Incoming phone call (14)
state: Incoming call [ caller:* ]
enter: Ring (15)
a1: Variable set [name:%volmsave to:%volm do maths:eek:ff append:eek:ff] 
a2: Media control [cmd:pause simulate media button:eek:n] 
a3: Media volume [level:%sane display:eek:ff sound:eek:ff] media volume [ %headphones ~ true ]
a4: Media volume [level:%volr display:eek:ff sound:eek:ff] media volume [ %headphones ~ false ]
a5: Music play [file:ringtones/ringtone.m4a start:30 loop:eek:ff]

exit: Kill ringer (17)
a1: Music stop [clear dir:eek:ff] 
a2: Media volume [level:%volmsave display:eek:ff sound:eek:ff] 
a3: Media control [cmd:toggle pause simulate media button:eek:n] media control [ %headphones ~ true ]
catches sms
Code:
profile: Sms (19)
event: Received text [ type:any sender:* content:* ]
enter: Beep (20)
a1: Variable set [name:%volmsave to:%volm do maths:eek:ff append:eek:ff] 
a2: Media control [cmd:pause simulate media button:eek:n] 
a3: Media volume [level:%sane display:eek:ff sound:eek:ff] media volume [ %headphones ~ true ]
a4: Media volume [level:%volr display:eek:ff sound:eek:ff] media volume [ %headphones ~ false ]
a5: Music play [file:ringtones/notification.mp3 start:0 loop:eek:ff] 
a6: Wait [ms:0 seconds:3 minutes:0 hours:0 days:0] 
a7: Music stop [clear dir:eek:ff] 
a8: Media volume [level:%volmsave display:eek:ff sound:eek:ff] 
a9: Media control [cmd:toggle pause simulate media button:eek:n] media control [ %headphones ~ true ]
works well on my phone. Automatically resumes music after ringer/sms if headphones are plugged in.

Comments, questions, suggestions welcome! Lemme know if this works on your phones.

please help, i have locked bootloader, a wt19a with xg! 2.3.7 rooted

how can i use that, anyone can explain me please!!!!
 

binlalo

Senior Member
Feb 5, 2012
422
49
0
It may be a bit late but could you export and upload the task and/or profiles for this tasker script? I tried implementing it myself but couldnt do it and I'm desperete to solve this problem once and for all. Thanks in advance.
 

bp787

Senior Member
Jan 30, 2009
124
10
0
For your headphone issue, you could try using Headset Button Controller from the play store. It enables you to use single/multiple/long presses to do different things. Works very well.
 

sanghaviraj

Senior Member
Apr 20, 2010
394
52
58
workaround for Bluetooth please

I'm using jabra wave Bluetooth headset,n it doesn't play phone ringtone, but a very low beep on every cal, can someone come up with a workaround,I don't even know if it's possible
 

jiijima

Member
Aug 2, 2013
18
0
0
I'm using jabra wave Bluetooth headset,n it doesn't play phone ringtone, but a very low beep on every cal, can someone come up with a workaround,I don't even know if it's possible
I haven't done much work with Tasker and bluetooth, but can you do a "notify sound" action when BT is connected? I don't know if it will route the "notify sound" to BT or play from the phone though. Or change the volume of your BT to max while ringing and low or something tolerable while on the call.
 

robertusIT

Senior Member
May 23, 2013
381
24
18
Palermo
you know how can get in my earphones the caller name and in the same time, in speaker phone the ring ?

i can hear the caller name in my earphones only when my phone is in vibrate mode.

but i need to get caller name in earphones and ring in speaker phone.