How does media button grab work?

301 views
Skip to first unread message

technogeezer

unread,
May 24, 2016, 8:11:01 AM5/24/16
to Tasker
I wanted to impress my girlfriend by having my car say something personal over its stereo speakers.  Thereafter, I wanted to have the music play dir action continuously play random tracks from my music folder.

I actually got this to work for a short time.  Even the album art and artists name, and the percent complete bar, would come up in my console.

Now it doesn't work and I can't figure out why.  I'm thinking I am not using 'grab' correctly.

Below are my profiles.  Task NewState is external and simply puts a nice icon up in the notification bar depending on what my phone is connected to.  WrtLog writes state info to a text file.


# This profile sets up tasker to work with the BT in my car
# On exit, it shuts down music play dir and cleans up
Profile: BTCar (127)
    State: BT Connected [ Name:* Address:xx:xx:xx:xx:xx:xx ]
Enter: Anon (128)
    A1: Media Button Events [ Action:Grab ]
    A2: Variable Set [ Name:%PlayCnt To:1 Do Maths:Off Append:Off ]
    A3: WiFi [ Set:Off ]
    A4: Media Volume [ Level:15 Display:Off Sound:Off ]
    A5: Perform Task [ Name:WrtLog Priority:%priority Parameter 1 (%par1):BT enter Parameter 2 (%par2): Return Value Variable: Stop:Off ]
    A6: Perform Task [ Name:NewState Priority:%priority Parameter 1 (%par1):stevestoy Parameter 2 (%par2): Return Value Variable: Stop:Off ]

Exit: Anon (129)
    A1: Media Button Events [ Action:Release ]
    A2: Music Stop [ Clear Dir:Off ]
    A3: Media Volume [ Level:13 Display:Off Sound:Off ]
    A4: WiFi [ Set:On ]
    A5: Perform Task [ Name:WrtLog Priority:%priority Parameter 1 (%par1):BT exit Parameter 2 (%par2): Return Value Variable: Stop:Off ]

# This profile intercepts music play from my car.
# This profile has two parts, the first plays a special file the first time this profile triggers.
# Thereafter, it plays random music tracks
Profile: MB Play (100)
    State: Media Button [ Button:Play Held Down:Off Grab:On Stop Event:On ]
Enter: Anon (133)
    A1: Beep [ Frequency:5724 Duration:100 Amplitude:82 Stream:3 ]
    A2: Beep [ Frequency:5724 Duration:100 Amplitude:82 Stream:3 ]
    A3: Perform Task [ Name:WrtLog Priority:%priority Parameter 1 (%par1):Music play %PlayCnt Parameter 2 (%par2): Return Value Variable: Stop:Off ]
    A4: If [ %PlayCnt eq 0 ]
    A5: Music Play Dir [ Dir:/storage/xxx/Music Subdirs:On Audio Only:On Random:On Flash:Off Maximum Tracks:0 ]
    A6: Else
    A7: [X] Music Play [ File:BTcon.wav Start:0 Loop:Off Stream:3 ]
    A8: Music Play [ File:a2m.wav Start:0 Loop:Off Stream:3 ]
    A9: [X] Music Play Dir [ Dir:/storage/xxx/Music Subdirs:On Audio Only:On Random:On Flash:Off Maximum Tracks:0 ]
    A10: Variable Subtract [ Name:%PlayCnt Value:1 Wrap Around:0 ]
    A11: End If

# This profile intercepts music stop from my car.  It shuts down music play dir.
Profile: MB Stop (76)
    State: Media Button [ Button:Pause / Stop Held Down:Off Grab:On Stop Event:On ]
Enter: Anon (148)
    A1: Beep [ Frequency:948 Duration:100 Amplitude:100 Stream:3 ]
    A2: Beep [ Frequency:948 Duration:100 Amplitude:100 Stream:3 ]
    A3: Music Stop [ Clear Dir:Off ]
    A4: Perform Task [ Name:WrtLog Priority:%priority Parameter 1 (%par1):Music stop Parameter 2 (%par2): Return Value Variable: Stop:Off ]

I put the two beeps in to indicate that tasker has intercepted something.  Sometimes, music plays but I don't hear the beep.  Sometimes nothing happens.  Every now and then, the phone and audio player repeatedly connect and disconnect.  What the heck am I doing wrong?!

Thanks

Reply all
Reply to author
Forward
0 new messages