cec-cdi is a CDI Extension to interface with libcec through cec-client
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/main
.gitignore
LICENSE
README.md
pom.xml

README.md

cec-cdi

cec-cdi is a CDI Extension to interface with libcec through cec-client.

Install

  1. Install cec-client in /usr/local/bin/cec-client (for Raspbian a premade deb is available)
  2. Add cec-cdi to pom.xml:
<dependency>
	<groupId>nl.edubits.cec</groupId>
	<artifactId>cec-cdi</artifactId>
	<version>1.0-SNAPSHOT</version>
</dependency>

Usage examples

Observe CEC messages

@ApplicationScoped
public class CecObserverBean {
	public void tvMessage(@Observes @CecSource(TV) Message message) {
		logger.info("Message received from TV: " + message);
	}
}

Send CEC message

public class SendExample {

	@Inject
	private CecConnection connection;
	
	public void send() {
		// Send message from RECORDER1 (by default the device running this code) to the TV to turn on
		connection.sendMessage(new Message(RECORDER1, TV, IMAGE_VIEW_ON, Collections.emptyList(), ""));
		
		// Send message from RECORDER1 (by default the device running this code) to the TV to turn off
		connection.sendMessage(new Message(RECORDER1, TV, STANDBY, Collections.emptyList(), ""));
	}
}

Resources