AutoNotification Auto Notification and Google play music

Discussion in 'AutoApps' started by Rich Wallace, Apr 10, 2015.

  1. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    I'm trying to create an auto notification intercept profile to intercept Google Play Music notifications, so I can grab the track, artist, album and cover art. With a view to replacing Media Utilities.
    However, my profile is firing multiple times, ie a tracknplays and the profile will fire more than once.
    I set up a basic flash to show me what's happening and it seems to be active, then inactive, the active again...?
    I've attached the profile description...

    Profile: AN Intercept Play Music (209)
    State: AutoNotification Intercept [ Configuration:Event Behaviour: true
    Notification Type: Only Created Notifications
    Persistency Type: Persistent Only
    Notification App: Google Play Music
    Package Name: com.google.android.music (exact)
    Get All Fields : true
    Big Text Names : track,artist,album
    Image Names : albumart ]
    Enter: Anon (211)
    A1: Flash [ Text:%track
    %artist
    %album
    %albumart Long:Off ]

    Exit: Anon (214)
    A1: Flash [ Text:Exit Long:Off ]
     
  2. Thahim

    Thahim Member

    Joined:
    Mar 1, 2015
    Messages:
    181
    Likes Received:
    5
    @Rich Wallace did you try %anid %anpackage variables instead of writing the values.
     
  3. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    That doesn't make any sense?
    I don't need the notification id or app package...
    Please reread my post carefully before replying.
     
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    That happens because the notification is updated several times by the music app usually
    You have to check in the task if the values are the same as the last notification and ignore them in that case. Hope this helps ☺
     
  5. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    Ah OK @joaomgcd
    I suspected this but was hip ng otherwise.
    Does it mean I need to set a global variable?
    I guess so?
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Yes, a global variable should do :)
     
  7. Evil Genius

    Evil Genius Member

    Joined:
    Mar 5, 2015
    Messages:
    112
    Likes Received:
    9
    Did you ever able get this working correctly? If so, could you show us a demo and how you did it? I too would be interested in this.
     
  8. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    Yes I did actually!
    Here is the profile description...
    (Ive removed some other Java function actions from the start....hence why it starts at A5...
    Profile: AN Intercept - Music Track Info (43)
    State: AutoNotification Intercept [ Configuration:Event Behaviour: true
    Notification Type: Only Created Notifications
    Notification Apps: Spotify,Google Play Music
    Get All Fields : true
    Text Names : track
    Big Text Names : big
    Image Names : albumart ]
    Enter: Anon (44)
    A5: If [ %TrackName eq %antitle ]
    A6: Stop [ With Error:Off Task: ]
    A7: Else
    A8: If [ %anapp eq Spotify ]
    A9: Variable Split [ Name:%antexts2 Splitter:— Delete Base:Off ]
    A10: Variable Set [ Name:%TrackName To:%antitle Do Maths:Off Append:Off ]
    A11: Variable Set [ Name:%TrackArtist To:%antexts21 Do Maths:Off Append:Off ]
    A12: [X] Flash [ Text:Artist = %antexts21
    Track = %antitle Long:On ]
    A13: Else If [ %anapp eq Google Play Music ]
    A14: Variable Set [ Name:%TrackCoverart To:%albumart Do Maths:Off Append:Off ]
    A15: Variable Set [ Name:%TrackName To:%antitle Do Maths:Off Append:Off ]
    A16: Variable Set [ Name:%TrackArtist To:%antexts3 Do Maths:Off Append:Off ]
    A17: [X] Flash [ Text:Song = %antitle
    Artist = %antexts3 Long:On ]
    A18: End If
    A19: End If
    A20: Flash [ Text:%anapp Long:Off ]

    This will work if you use Play Music and Spotify, but can be adapted to work with as many media players as you please, just add in additional 'Else if [%anapp eq MEDIA PLAYER]' conditions.
     
  9. Evil Genius

    Evil Genius Member

    Joined:
    Mar 5, 2015
    Messages:
    112
    Likes Received:
    9
  10. boppy

    boppy New Member

    Joined:
    Nov 3, 2016
    Messages:
    2
    Likes Received:
    0
    I took some other approach that might be some kind of off topic since it doesn't use auto notification.

    Using the broadcasted intend com.android.music.metachanged has some great advantages. But first: No Cover Art! ;(

    Code (Text):
    Event: Intent Received [ Action:com.android.music.metachanged Cat:None Cat:None Scheme:* Mime Type:* ]

    A1: Variable Set [ Name:%TrackCurrentShort To:%track - %artist Do Maths:Off Append:Off ]
    A2: Variable Set [ Name:%TrackCurrent To:%track - %artist
    (%album) Do Maths:Off Append:Off ]
    I found some nice documents on the net after finding out the Intent name. Two to be mentioned:
    Hybrid- Analysis Facebook APK Analysis since - if there is anybody - tracking anything going on on your device it will be Facebook. Searching for the mentioned intent, you'll see quite a nice list of other intents that might catch your interest. PROtip: Don't read through the list if you have Facebook installed... Just saying :p

    Source Code of a Broadcast Receiver used by a lyrics-app for giving a nice overview of available intent extras.

    My Google Play Music sends (just prepend a "%" for tasker usage; all conversions are done):
    Code (Text):
    streaming: true
    position: 42514
    album: Smokid Inc.
    currentsongloaded: true
    track: Have a Look Out
    listposition: 6
    listsize: 52
    playing: true
    duration: 213000
    previewplaytype: -1
    supportsrating: true
    domain: 2
    artist: Smokey Joe & The Kid
    rating: 5
    local: true
    preparing: false
    inerrorstate: false
    Not tired reading? ^^ Okay, let one last thing be said:

    This intent is not only fired by play music but also by many other apps! I can proof that for Spotify and YouTube. But even my email-app's default audio player app sends that one. I found that out wile checking my "played tracks" log. ;-) So I think most audio playing apps will fire that very intent. So it's great to create a playlist after an evening. I store some info beside the mentioned to be able to create some - more or less - fancy Playlist:
    https://api.kruu.de/files/playlist.html - I was just playing around with google charts api -- It's easy!
     
  11. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    @boppy Awesome :D Just added that to AutoTools beta! Will be a new event condition called "Media State". Thank you for sharing that!

    BTW, any idea how to get the currently playing song cover art? :)
     
    boppy likes this.
  12. boppy

    boppy New Member

    Joined:
    Nov 3, 2016
    Messages:
    2
    Likes Received:
    0
    Just to complete that one. I found all data needed (if on google). The key is %anicon()! It provides the album cover as local file! Details for all functions that return something with Play Music:
    Code (Text):
    %anbutton1action()   Button Action 1        ~ LIKE               <id>
    %anbutton1text()     Button 1 Text          LIKE                 Mag ich
    %anbutton2action()   Button 2 Action        ~ PREV TRACK         <id>
    %anbutton2text()     Button 2 Text          PREV TRACK           Zurück
    %anbutton3action()   Button 3 Action        ~ PAUSE              <id>
    %anbutton3text()     Button 3 Text          PAUSE                Pausieren
    %anbutton4action()   Button 4 Action        ~ NEXT TRACK         <id>
    %anbutton4text()     Button 4 Text          NEXT TRACK           Weiter
    %anbutton5action()   Button 5 Action        ~ DISLIKE            <id>
    %anbutton5text()     Button 5 Text          DISLIKE              Mag ich nicht
    %andismissaction()   Action On Dismiss Id                        <id>
    %anicon()            Icon                   ALBUM ART (HiRes)    file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_-102440555
    %ansubtext()         SubText                Album Title          Jirafa Waves
    %antextbig()         Text When Expanded     Artist               Kid Simius
    %antitlebig()        Title When Expanded    Track Name           Solid Ground (feat. Rebellion The Recaller)

    # LESS IMPORTANT ;)
    %anapp()             App name               Google Play Musik
    %anbutton1icon()     Button 1 Icon          file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_-1803146057
    %anbutton2icon()     Button 2 Icon          file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_-1802222536
    %anbutton3icon()     Button 3 Icon          file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_-1801299015
    %anbutton4icon()     Button 4 Icon          file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_-*
    %anbutton5icon()     Button 5 Icon          file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_-*
    %ankey()             Unique instance        0|com.google.android.music|1|null|10060
    %anpackage()         Package Name           com.google.android.music
    %anstatusbaricon()   Status Bar Icon        file:///storage/emulated/0/Android/data/com.joaomgcd.autonotification/files/com.google.android.music_3226745
    %antext()            Text                   Kid Simius
    %antitle()           Title                  Solid Ground (feat. Rebellion The Recaller)
    %antouchaction()     Action On Touch Id     <id>
    %anwhen()            Show When              false
     
    [edit @ + 10']
    added missing %anbutton4icon() and %anbutton5icon().
     
    Last edited: Dec 31, 2016

Share This Page