Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media session title #250

Open
Drafteed opened this issue Jun 14, 2021 · 1 comment
Open

Media session title #250

Drafteed opened this issue Jun 14, 2021 · 1 comment

Comments

@Drafteed
Copy link

Drafteed commented Jun 14, 2021

Hello @JeffLIrion! Thx for work!

dumpsys media_session return the title of the content being played in the metadata:description field for apps that use media_session API (YouTube, Spotify, ViMu, Netflix, TiviMate etc..).

Is it possible to make this information used in HA media_title, media_artist, media_album if it provided and active? Like Google Cast integration do. Also i see current media position meta.


  6 sessions listeners.
  Global priority session is null
  User Records:
  Record for full_user=0
    Volume key long-press listener: null
    Volume key long-press listener package: 
    Media key listener: null
    Media key listener package: 
    Callback: android.media.session.ICallback$Stub$Proxy@7f2bc79
    Last MediaButtonReceiver: null
    Restored MediaButtonReceiver: null
    Media button session is com.google.android.youtube.tv/starboard_media (userId=0)
    Sessions Stack - have 4 sessions:
      starboard_media com.google.android.youtube.tv/starboard_media (userId=0)
        ownerPid=25681, ownerUid=10048, userId=0
        package=com.google.android.youtube.tv
        launchIntent=null
        mediaButtonReceiver=null
        active=true
        flags=3
        rating type=0
        controllers: 12
        state=PlaybackState {state=3, position=1980379, buffered position=0, speed=1.0, updated=38059080, actions=379, custom actions=[], active item id=-1, error=null}
        audioAttrs=AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN flags=0x0 tags= bundle=null
        volumeType=1, controlType=2, max=0, current=0
        metadata:size=5, description=Introducing iPad Pro | Apple, Apple, null
        queueTitle=null, size=0

      spotify-android-tv-media-session com.spotify.tv.android/spotify-android-tv-media-session (userId=0)
        ownerPid=4636, ownerUid=10071, userId=0
        package=com.spotify.tv.android
        launchIntent=null
        mediaButtonReceiver=PendingIntent{8775afa: PendingIntentRecord{fe618ab com.spotify.tv.android broadcastIntent}}
        active=false
        flags=3
        rating type=0
        controllers: 0
        state=PlaybackState {state=0, position=30357, buffered position=0, speed=1.0, updated=36002007, actions=2368383, custom actions=[], active item id=-1, error=null}
        audioAttrs=AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN flags=0x0 tags= bundle=null
        volumeType=1, controlType=2, max=0, current=0
        metadata:size=7, description=Counting Days Till Suicide, REDZED, Ecstasy
        queueTitle=null, size=0

      Netflix media session com.netflix.ninja/Netflix media session (userId=0)
        ownerPid=5525, ownerUid=10063, userId=0
        package=com.netflix.ninja
        launchIntent=null
        mediaButtonReceiver=null
        active=false
        flags=3
        rating type=0
        controllers: 0
        state=null
        audioAttrs=AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN flags=0x0 tags= bundle=null
        volumeType=1, controlType=2, max=0, current=0
        metadata:size=0, description=null
        queueTitle=null, size=0

      starboard_media com.google.android.youtube.tv/starboard_media (userId=0)
        ownerPid=25681, ownerUid=10048, userId=0
        package=com.google.android.youtube.tv
        launchIntent=null
        mediaButtonReceiver=null
        active=false
        flags=3
        rating type=0
        controllers: 0
        state=PlaybackState {state=0, position=0, buffered position=0, speed=0.0, updated=0, actions=0, custom actions=[], active item id=-1, error=null}
        audioAttrs=AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN flags=0x0 tags= bundle=null
        volumeType=1, controlType=2, max=0, current=0
        metadata:size=0, description=null, null, null
        queueTitle=null, size=0

  Audio playback (lastly played comes first)
    uid=10048 packages=com.google.android.youtube.tv
@JeffLIrion
Copy link
Owner

Short answer: that should work.

Long answer...

When I first created this package, the ADB library was not very reliable for newer devices. In an effort to make it work better, I used a single ADB command for the update function. This wasn't so bad at first, the command was reasonably short. But as more info got collected by the update function, this ADB command grew in complexity.

To accomplish what you're describing, it's probably better to split the update function into multiple ADB commands, since the ADB library that it uses now (adb-shell) is pretty reliable. First, check simple stuff, like if the device is on and awake. Then check stuff like the current app and the fields you mentioned. And maybe instead of using a complicated grep command to parse the dumpsys output on the device, just return the full output and parse it in this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants