使用请求控制Vlc-Java [英] Control Vlc with requests - java

查看:75
本文介绍了使用请求控制Vlc-Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 http://localhost:8080

问题是我不知道我必须如何使用http请求.这是我写的一些代码:

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);

它主要是从Google复制/粘贴.状态返回200.

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

推荐答案

我只需要读取连接的响应!

I just had to read the response from the connection!

这篇关于使用请求控制Vlc-Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆