Control Vlc with requests - java

你离开我真会死。 提交于 2021-01-29 14:37:12

问题


I want to control vlc with java code and its web interface using http://localhost:8080

The problem is I don't know how exactly I must use the http requests. Here is some code I have written:

URL url = new URL("http://127.0.0.1:8080/");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("GET");
con.setRequestProperty("If-Modified-Since", "29 Oct 1999 19:43:31 GMT");
con.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
con.setRequestProperty("Content-Language", "en-US");

//DataOutputStream wr = new DataOutputStream(con.getOutputStream());

OutputStream wr = con.getOutputStream();
if (line.split(":")[1].equals("Play")) {
      wr.write("requests/status.xml?command=pl_play".getBytes());
//          wr.write("play".getBytes());
    }
    else {
          wr.write("requests/status.xml?command=pl_stop".getBytes());
    }
    wr.flush();
    //wr.close();
    int status = con.getResponseCode();
    System.out.println(status);

It mainly copy/paste from google. Status returns 200..


回答1:


I just had to read the response from the connection!



来源:https://stackoverflow.com/questions/22026684/control-vlc-with-requests-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!