How can I make an Android Box be recognized as Media Player?

I have an Android Box with multiple streaming & media-managing apps:

  • Kodi (For my NAS content)
  • Netflix
  • Hulu
  • XfinityTV (For Live TV)

My question is how can I make the Android Box be seen as a media player entity in order to control playback (Pause, play, fast forward, rewind)? I have it plugged into a smart switch, so I can control the on/off state of it via that switch on my HA interface, but don’t know how to control the media aspects of it since it isn’t an Android TV. It’s basically running Android as a stationary phone. I’d like a non-hacky solution that doesn’t rely on Tasker & Tasker plugins if possible. Hopefully there’s a way to specify it as a media element in my configuration.yaml file?

I think currently there are only hacky ways to do this, if at all. Have a look at this thread, or generally search the forum for android control using adb commands.

There’s no way to make it show up as, say, a Chromecast? I just need the ability to pause and play basically.

Not that I’m aware of. It just isn’t a Chromecast. I think there once was an app that would emulate being a chromecast, but that got removed from the app store since of course Google wants to sell their hardware instead of people just installing a special app to reuse existing hardware.

Any chance you recall the name of the app? Ideally there’d still be an apk available somewhere on the internet.

Nope, never used it. Just Google for something like Android Chromecast App or similar.

Hmm, I’m a bit at a loss. See, I don’t really need it to fully imitate a Chromecast. I just need to be able to detect current state (playing, paused, idle) :thinking:

The problem is, that there is no real playing state. When is the device playing? When Netflix is playing? When Spotify is playing? We know that with the chromecast because it’s just a single “app” where content is streaming to. But with a full Android device it’s not that easy.
Anyway, I still don’t know of an easy way to do what you want to do. The closest thing I know of is the manual adb-stuff I have mentioned above. If that’s not an option for you I think you are out of luck.

Kodi has a component.

You might be able to modify this Fire TV component to work for an Android box. https://github.com/JeffLIrion/homeassistant_native_firetv

There’s a short discussion about Fire TV vs. Android here: https://github.com/happyleavesaoc/python-firetv/issues/13

2 Likes

Oh, this looks promising! I can’t tell with a simple skim of the component, but does it support the reporting of the “media_player’s” state? Like, will HA be able to report whether it’s playing something or paused, etc? Sorry that I can’t look too much into the component at the moment (I’m on mobile and won’t be near a computer until much later today).

Hopefully someday this will be merged.

https://github.com/home-assistant/home-assistant/pull/16975

Can we escalate this to get more support behind that PR? This is exactly what I’m looking for. But, if it’s far off from being incorporated I’ll likely try implementing the firetv component and seeing if my Android box works with it.

I am also looking for this functionality with my Nvidia Shield TV!

Did you add androidtv.py to config/components/media_player? I tried but getting error messages. And when removing error message still is there.

How about you? Did it work and if so how did you add everything?

I haven’t had a chance to try incorporating it yet. What’s the error message?

Removed everything so will have to try again to get the error message. I was mostly suspecting that I had done something wrong.

But you said the error messages are still there…

Sorry, they disappeared after another restart of HA.

It’s actually doable, one trick is to check the state of the audio output tracks, if there is audio comming out then the state is playing.

Although I couldn’t manage to get more info, like current playing media metadata. One way I thought about is with the notification system, I don’t if it’s everywhere the same but on my Mibox I have a now playing notification with everything needed. Though I could’t find anything from an ADB command to fetch it. Will continue to look! :slight_smile:

1 Like