mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-04 15:06:03 +00:00
Fix UI jank. Add support for pairing. Add missing XML parsing jar.
This commit is contained in:
@@ -3,5 +3,6 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="libs/limelight-common.jar"/>
|
||||
<classpathentry kind="lib" path="libs/xpp3-1.1.4c.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
BIN
limelight-pc/libs/xpp3-1.1.4c.jar
Normal file
BIN
limelight-pc/libs/xpp3-1.1.4c.jar
Normal file
Binary file not shown.
@@ -1,5 +1,8 @@
|
||||
package com.limelight.binding;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import com.limelight.binding.audio.JavaxAudioRenderer;
|
||||
import com.limelight.binding.video.SwingCpuDecoderRenderer;
|
||||
import com.limelight.nvstream.av.audio.AudioRenderer;
|
||||
@@ -11,7 +14,11 @@ public class PlatformBinding {
|
||||
}
|
||||
|
||||
public static String getDeviceName() {
|
||||
return "foobar";
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
return "LimelightPC";
|
||||
}
|
||||
}
|
||||
|
||||
public static AudioRenderer getAudioRenderer() {
|
||||
|
||||
@@ -5,26 +5,37 @@ import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import com.limelight.Limelight;
|
||||
import com.limelight.binding.PlatformBinding;
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
import com.limelight.nvstream.http.NvHTTP;
|
||||
|
||||
public class MainFrame {
|
||||
private JTextField hostField;
|
||||
private JButton pair;
|
||||
private JButton stream;
|
||||
private JFrame limeFrame;
|
||||
|
||||
public MainFrame() {
|
||||
}
|
||||
|
||||
public void build() {
|
||||
JFrame limeFrame = new JFrame("Limelight V" + Limelight.VERSION);
|
||||
limeFrame = new JFrame("Limelight V" + Limelight.VERSION);
|
||||
limeFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
Container mainPane = limeFrame.getContentPane();
|
||||
|
||||
@@ -57,9 +68,15 @@ public class MainFrame {
|
||||
pairBox.add(pair);
|
||||
pairBox.add(Box.createHorizontalGlue());
|
||||
|
||||
Box hostBox = Box.createHorizontalBox();
|
||||
hostBox.add(Box.createHorizontalStrut(20));
|
||||
hostBox.add(hostField);
|
||||
hostBox.add(Box.createHorizontalStrut(20));
|
||||
|
||||
|
||||
Box contentBox = Box.createVerticalBox();
|
||||
contentBox.add(Box.createVerticalStrut(20));
|
||||
contentBox.add(hostField);
|
||||
contentBox.add(hostBox);
|
||||
contentBox.add(Box.createVerticalStrut(10));
|
||||
contentBox.add(streamBox);
|
||||
contentBox.add(Box.createVerticalStrut(10));
|
||||
@@ -69,8 +86,9 @@ public class MainFrame {
|
||||
|
||||
centerPane.add(contentBox);
|
||||
mainPane.add(centerPane, "Center");
|
||||
|
||||
limeFrame.setSize(1000, 800);
|
||||
|
||||
limeFrame.setSize(300, 175);
|
||||
limeFrame.setResizable(false);
|
||||
limeFrame.setVisible(true);
|
||||
|
||||
}
|
||||
@@ -85,6 +103,56 @@ public class MainFrame {
|
||||
}
|
||||
|
||||
private ActionListener createPairButtonListener() {
|
||||
return null;
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String macAddress;
|
||||
try {
|
||||
macAddress = NvConnection.getMacAddressString();
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (macAddress == null) {
|
||||
System.out.println("Couldn't find a MAC address");
|
||||
return;
|
||||
}
|
||||
|
||||
NvHTTP httpConn;
|
||||
String message;
|
||||
try {
|
||||
httpConn = new NvHTTP(InetAddress.getByName(hostField.getText()),
|
||||
macAddress, PlatformBinding.getDeviceName());
|
||||
try {
|
||||
if (httpConn.getPairState()) {
|
||||
message = "Already paired";
|
||||
}
|
||||
else {
|
||||
int session = httpConn.getSessionId();
|
||||
if (session == 0) {
|
||||
message = "Pairing was declined by the target";
|
||||
}
|
||||
else {
|
||||
message = "Pairing was successful";
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
message = e.getMessage();
|
||||
} catch (XmlPullParserException e) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
} catch (UnknownHostException e1) {
|
||||
message = "Failed to resolve host";
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(limeFrame, message, "Limelight", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user