View on GitHub

jdial

A DIAL client implementation in plain java

JDial

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.

Dependency declaration

You can find the latest release in the sonatype repository.

Maven

<dependency>
    <groupId>de.w3is</groupId>
    <artifactId>jdial</artifactId>
    <version>1.6</version>
</dependency>

Gradle

implementation 'de.w3is:jdial:1.6'

Usage

Discover

List<DialServer> devices = new Discovery().discover();

Creat a DialClientConnection

DialServer dialServer = devices.get(0);
DialClient dialClient = new DialClient();

DialClientConnection tv = dialClient.connectTo(dialServer);

Discover applications

Application youtube = tv.getApplication(Application.YOUTUBE);

Start applications

tv.startApplication(youtube);

Stop applications

tv.stopApplication(youtube);

Implement application vendor protocol


 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)

Legacy support

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

Logging is done via java util logging.