मैंने पहले से ही यह धागा देखा है, लेकिन मुझे अभी भी कोई समस्या है: starting vlc player in java ऐसा लगता है कि वीएलसी के लिए जावा बाइंडिंग सक्रिय विकास में नहीं हैं और सब कुछ का समर्थन नहीं करते हैं वैसे भी कमांड लाइन पर संभव है।जावा में वीएलसी लॉन्च करें और आरसी इंटरफेस के माध्यम से इसे कनेक्ट करें
निम्नलिखित कोड को देखते हुए, मैं मैक ओएस 10.5.8 (जावा 1.6) पर जावा एप्लिकेशन से वीएलसी लॉन्च नहीं कर सकता और फिर टर्मिनल या किसी अन्य जावा एप्लिकेशन के माध्यम से आरसी इंटरफ़ेस के माध्यम से इसे कनेक्ट नहीं कर सकता।
public class TelnetTest {
public static void main(String args[]) {
TelnetClient tl = new TelnetClient();
try {
tl.connect("localhost", 4444);
if(tl.isConnected()) {
System.out.println("Connected successfully!");
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(tl.getOutputStream()));
bw.write("quit");
bw.flush();
} else {
System.err.println("Problem with connection");
}
} catch(Exception e) {
System.err.println("Telnet connection threw an exception: "+e.getMessage());
}
}
}
:
public class Main {
public static void main(String[] args) {
String s = null;
try {
//Process p = Runtime.getRuntime().exec("/Applications/VLC.app/Contents/MacOS/VLC -I telnet --telnet-host=localhost:4442 -I rc --rc-host=localhost:4444");
//Process p = Runtime.getRuntime().exec("/Applications/VLC.app/Contents/MacOS/VLC -I rc --rc-host=localhost:4444");
//ProcessBuilder pb = new ProcessBuilder("/Applications/VLC.app/Contents/MacOS/VLC","-I rc","--rc-host=localhost:4444");
ProcessBuilder pb = new ProcessBuilder("/Applications/VLC.app/Contents/MacOS/VLC","-IRC","--rc-host=localhost:4444");
Process p = pb.start();
StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), false);
StreamGobbler inputGobbler = new StreamGobbler(p.getInputStream(), false);
errorGobbler.start();
inputGobbler.start();
System.out.println("Waiting: \n"+p.waitFor());
System.out.println("All done here");
//p.destroy();
//System.exit(0);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception ie) {
ie.printStackTrace();
}
}
}
class StreamGobbler extends Thread {
InputStream is;
boolean discard;
StreamGobbler(InputStream is, boolean discard) {
this.is = is;
this.discard = discard;
}
public void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ((line = br.readLine()) != null)
if(!discard)
System.out.println(line);
}
catch (IOException ioe) {
ioe.printStackTrace();
}
} }
यहाँ अपाचे कॉमन्स नेट पैकेज है कि मैं एक ही मशीन पर चल रहा है ऊपर एप्लिकेशन से कनेक्ट करने के कोशिश कर रहा हूँ का उपयोग कर जावा अनुप्रयोग है बाद वाला ऐप ठीक काम करता है अगर मैं टर्मिनल में पहले एप से कमांड का उपयोग करके वीएलसी शुरू करता हूं। इसी तरह, मैं टर्मिनल में "टेलनेट लोकहोस्ट 4444" का उपयोग कर टर्मिनल से पहले ऐप से कनेक्ट नहीं कर सकता।
वीएलसी से आउटपुट में मुझे जो अंतर मिल सकता है वह है। जब टर्मिनल में चल रहा है:
[0x2786e8] main interface error: no interface module matched "globalhotkeys,none"
[0x2786e8] main interface error: no suitable interface module
[0x201b28] main libvlc error: interface "globalhotkeys,none" initialization failed
Remote control interface initialized. Type `help' for help.
जब शीर्ष जावा आवेदन के माध्यम से क्रियान्वित:
[0x4009178] main interface error: no interface module matched "globalhotkeys,none"
[0x4009178] main interface error: no suitable interface module
[0x2017a8] main libvlc error: interface "globalhotkeys,none" initialization failed
[0x4009178] main interface error: no suitable interface module
[0x2017a8] main libvlc error: interface "default" initialization failed
किसी को भी मुझे यहाँ मदद कर सकते हैं? मुझे हानि हो रही है। आपका बहुत बहुत धन्यवाद।
इस लागू करने के लिए इच्छुक किसी को भी करने के लिए, ध्यान दें प्रत्येक आदेश के अंत में "\ n"। यह भी ध्यान रखें कि आउटपुट स्ट्रीम को बंद करने से वीएलसी इंस्टेंस बंद हो जाएगा। ये दो चीजें थीं जो मुझे पकड़ा। –