JDial is an plain java implementation of the Discovery and Launch (DIAL) protocol version 2.1 defined by Netflix and YouTube.
DIAL allows second screen devices (smartphone, laptop, ...) to discover server instances in the local network and launch applications on a first screen device (smart TV).
For additional information about the protocol see Wikipedia and dial-multiscreen.org.
A list of reserved application names can also be found on the dial-multiscreen.org site.
JDial has no dependencies to any library and can therefore be integrated in every program and app.
You can find the latest release in the sonatype repository.
<dependency>
<groupId>de.w3is</groupId>
<artifactId>jdial</artifactId>
<version>1.6</version>
</dependency>
implementation 'de.w3is:jdial:1.6'
List<DialServer> devices = new Discovery().discover();
DialServer dialServer = devices.get(0);
DialClient dialClient = new DialClient();
DialClientConnection tv = dialClient.connectTo(dialServer);
Application youtube = tv.getApplication(Application.YOUTUBE);
tv.startApplication(youtube);
tv.stopApplication(youtube);
DialContent content = new DialContent() {
@Override
public String getContentType() {
return "application/json; encoding=UTF-8";
}
@Override
public byte[] getData() {
return "{}".getBytes(Charset.forName("UTF-8"));
}
};
myTv.startApplication(youtube, content)
Some server implementations are not compatible with current versions of the DIAL protocol.
For example some LG TVs support DIAL, but the server implementation can't handle query parameters.
By creating a ProtocolFactoryImpl and setting the legacyCompatibility
flag the client doesn't set any query parameter.
bool supportLegacyDevices = true;
ProtocolFactory factory = new ProtocolFactoryImpl(supportLegacyDevices);
DialClient dialClient = new DialClient(factory);
Logging is done via java util logging.