AutoPlay YouTube Vanced after Bluetooth disconnect

18 views
Skip to first unread message

Erik Carlin

unread,
Jun 27, 2022, 1:00:24 PMJun 27
to Tasker
Hello, 
Posted this in the XDA forums but thought I'd try Tasker forums - any insight would be appreciated. 
Reddit post too... Reddit

Here is a copy and paste from XDA with my problem and inquiry. Thanks!
---
Hello,

I came across XDA in my various searches for Tasker and media related inquiries. I posted this originally on Reddit and got some replies and made some things happen but it seems I've hit a dead end. What I would like to do is have my YouTube Vanced auto restart playback when I am reconnected to my car. Depending on the sequence of things, at times, the application can be paused (with the play button visible in the mini-player) and other times it has a pause button displayed in the mini player and won't initiate playback after turning back on the car.

I've been able to follow this description left by a user on Reddit - which has allowed me to playback any "APM Policy Manager start and stop output". It works with the toast notification but alas if my car is turned off and I see the pause button and not the play button, it won't continue playback on connection. My car seems to send a disconnect message and therefore I see the pause button - my headphones seem to send a pause and therefore I see a play button on the mini-player if they are ever disconnected.

Initially we are acting on logcat messages - perhaps I thought about deciphering the difference between my car disconnect message and the headphone disconnect message but I am not sure. Here is the code to make this happen - anyone try the same thing?

Profile: LP-MEDIA-DETECT

Settings: Enforce: no Notification: no

Event: Logcat Entry [ Output Variables:* Component:APM_AudioPolicyManager Filter:startOutput() Grep Filter (Check Help):Off ]

Enter Task: media-DETECT

Settings: Run Both Together

A1: [X] Multiple Variables Set [

Names: %lp_media_apps

Variable Names Splitter: #

Values: youtube|maxmpz|newpipe|bbc.sound|kodi|mx|

Values Splitter: #

Max Rounding Digits: 3 ]

A2: Run Shell [

Command: dumpsys media_session

Timeout (Seconds): 0

Store Output In: %data

Use Global Namespace: On ]

A3: Variable Search Replace [

Variable: %data

Search: (?<=packages=).*?(?=\s)

Store Matches In Array: %app ]

A4: Stop [ ]

If [ %app1 !~R %lp_media_apps ]

A5: Variable Set [

Name: %LP_STATE

To: 1

Max Rounding Digits: 3 ]

A6: Variable Search Replace [

Variable: %app1

Search: .unlock

Replace Matches: On

Continue Task After Error:On ]

If [ %app1 ~R maxmpz ]

A7: Variable Set [

Name: %lp_media_app

To: %app1

Max Rounding Digits: 3 ]

If [ %app1 !~ (?i)%lp_media_app & %app1 ~R (?i)%lp_media_apps ]

A8: Flash [

Text: %app1

Tasker Layout: On

Background Colour: #FF000000 ]

EXIT

[MEDIA STOP] PROFILE it's the same profile name and other filter

Profile: LP-MEDIA-DETECT

Settings: Notification: no

Event: Logcat Entry [ Output Variables:* Component:APM_AudioPolicyManager Filter:stopOutput() Grep Filter (Check Help):Off ]

Enter Task: media-EXIT

Settings: Run Both Together

A1: Run Shell [

Command: dumpsys media_session

Timeout (Seconds): 0

Store Output In: %data

Use Global Namespace: On ]

A2: Variable Search Replace [

Variable: %data

Search: (?<=packages=).*?(?=\s)

Store Matches In Array: %app ]

A3: Stop [ ]

If [ %app1 !~R %lp_media_apps ]

A4: Variable Clear [

Name: %LP_STATE ]

A5: Stop [ ]

A6: [X] Flash [

Text: %app1

Continue Task Immediately: On

Dismiss On Click: On ]


Here is the Reddit link as well: YouTube Vanced - AutoPlay

I have had some success with making a task with Play (simulated) on %app1 etc... but %app1 can change to the display or .... LED cover if the screen is just opened on my phone... etc. I've even tried Open App, %app1, or YouTube Vanced... simulate play or toggle paused... no avail.

Can you intercept the bluetooth disconnect message in a logcat and block it? Or change it to something? Is Tasker the right tool for all automation ideas? I have tried MacroDroid, Automate... they seem more userfriendly but then I found myself left underwhelmed - perhaps my lack of experience and knowledge is the only factor.

Cheers,

Reply all
Reply to author
Forward
0 new messages