I am using a PlugPC (compute stick) with Android version 4.4.4, connecting it to HDMI port of TV to control what is being displayed on the TV. My app starts on boot, taking control of the screen. Now through my app I want to control TV volume and source switch (maybe). I have following questions in this regard:
Is there a way to send HDMI-CEC commands via android using Java to control TV volume, switch on/off, etc on those TVs compatible ?
Any Java library provided by android or otherwise available for the same ?
A simple Java example using CEC.
P.S - I understand the theory presented in the (https://source.android.com/devices/tv/HDMI-CEC.html), but clueless on how to implement with code. Please be specific with your answers to above questions.
CEC (Consumer Electronics Control) allows for HDMI devices to be controlled with one remote control. If you try to cast to a CEC supported TV while on a different source input (local TV channel, Cable, USB), source input will automatically switch to the HDMI port where the Chromecast is connected.
Connect the wireless display adapter into your TV's open HDMI port and into a power outlet. Change the input source on your TV to the appropriate HDMI input. In the settings menu of your Android, open the “wireless display” application. Select your adapter from the list of available devices.
Just press the Menu button on your TV remote and open “Setup”. Next, navigate to “HDMI Control” and then open “CEC”. Finally, turn on the toggle. There you have it!
Yes it is entirely possible to do, however it is incredibly fickle. HDMI CEC works like a bus. Usually, in both directions.
Your questions:
Some of my own points:
To do it properly you will likely need to implement your code using JNI to form the proper packets. You might find this useful, at least for Amlogic.
The device access point that I use in my devices is /dev/amhdmitx0
. You can send your well formed packets to that location.
Here is a useful website that can tell you how how to form a CEC command: http://www.cec-o-matic.com/.
Unfortunately, I cannot share much more than this of what I have written. For various legal reasons.
The best thing that you can do is to seek help from the vendor you are programming for. If you are coding for a specific platform. They might be willing to help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With