aboutsummaryrefslogtreecommitdiff
path: root/tools/EventClients/examples/java/XBMCDemoClient1.java
blob: 5bb2821eb4f71db5807a1de489aef891218deff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package org.xbmc.eventclient.demo;

import java.io.File;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.InetAddress;

import org.xbmc.eventclient.XBMCClient;

/**
 * Simple Demo EventClient
 * @author Stefan Agner
 *
 */
public class XBMCDemoClient1 {

	/**
	 * Simple Demo EventClient
	 * @param args
	 */
	public static void main(String[] args) throws IOException, InterruptedException {
		InetAddress host = Inet4Address.getByAddress(new byte[] { (byte)127, 0, 0, 1 } );

		Thread.sleep(20000);

		String iconFile = "/usr/share/xbmc/media/icon.png";

		if (! new File(iconFile).exists()) {
			iconFile = "../../icons/icon.png";

			if (! new File(iconFile).exists()) {
				iconFile = "";
			}
		}

		XBMCClient oXBMCClient = null;

		if (iconFile != "") {
			oXBMCClient = new XBMCClient(host, 9777, "My Client", iconFile);
		} else {
			oXBMCClient = new XBMCClient(host, 9777, "My Client");
		}

		Thread.sleep(7000);

		oXBMCClient.sendNotification("My Title", "My Message");


		Thread.sleep(7000);

		oXBMCClient.sendButton("KB", "escape", false, true, false, (short)0 , (byte)0);


		Thread.sleep(7000);
		oXBMCClient.sendButton("KB", "escape", true, true, false, (short)0 , (byte)0);
		oXBMCClient.sendNotification("My Title", "Escape sent");

		Thread.sleep(1000);

		oXBMCClient.sendButton("KB", "escape", true, false, false, (short)0 , (byte)0);
		oXBMCClient.sendNotification("My Title", "Escape released");

		Thread.sleep(7000);
		oXBMCClient.sendLog((byte)0, "My Client disconnects....");
		oXBMCClient.sendNotification("My Title", "Client will disconnect");
		oXBMCClient.stopClient();

	}

}