mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-05-26 06:20:20 -04:00
添加投屏
This commit is contained in:
parent
191df67125
commit
aeac3008b4
37
app/src/main/java/org/sifacai/vlcjellyfin/Dlna/Utils.java
Normal file
37
app/src/main/java/org/sifacai/vlcjellyfin/Dlna/Utils.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package org.sifacai.vlcjellyfin.Dlna;
|
||||||
|
|
||||||
|
import java.net.Inet4Address;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取本机IPV4地址
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getIpAddress4() {
|
||||||
|
try {
|
||||||
|
Enumeration<NetworkInterface> allNetInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
InetAddress ip = null;
|
||||||
|
while (allNetInterfaces.hasMoreElements()) {
|
||||||
|
NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
|
||||||
|
if (netInterface.isLoopback() || netInterface.isVirtual() || !netInterface.isUp()) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
Enumeration<InetAddress> addresses = netInterface.getInetAddresses();
|
||||||
|
while (addresses.hasMoreElements()) {
|
||||||
|
ip = addresses.nextElement();
|
||||||
|
if (ip != null && ip instanceof Inet4Address) {
|
||||||
|
return ip.getHostAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("IP地址获取失败" + e.toString());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user