public void postVideoURL() throws IOException {
String appRunLocation = "";
URL obj = new URL("http://10.50.0.105:8060/dial/dev?url=http%3A%2F%2Fvideo.ted.com%2Ftalks%2Fpodcast%2FDavidBrooks_2011.mp4");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//add request header
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/plain; charset=\"utf-8\"");
String urlParameters = "videoUrl=" + URLEncoder.encode("video-url", "UTF-8");
urlParameters += "&streamFormat=hls";
String play_start = "0";
urlParameters += "&play_start=" + play_start;
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
try {
wr.writeBytes(urlParameters);
} catch (IOException e) {
e.printStackTrace();
}
try {
wr.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
wr.close();
} catch (IOException e) {
e.printStackTrace();
}
//BufferedReader in = new BufferedReader(
// new InputStreamReader(con.getInputStream()));
// String inputLine;
// StringBuffer response = new StringBuffer();
//appRunLocation = getHeader(con, RUN_LOCATION);
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
}
sub Main(launchParameters)
' don't do anything unless we got a url
if launchParameters.url <> invalid
' setup a poster screen and assign it a message port
port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)
' build a content-meta-data using the passed in URL
screen.SetContent({
stream: { url: launchParameters.url }
})
screen.SetPositionNotificationPeriod(1)
'screen.SetContent({
' stream: { url: launchParameters.url }
' })
msg = Wait(10000, port)
' play the video
'waitMess = print "Waiting for video..."
screen.Show()
end
end sub
String urlParameters = "videoUrl=" + URLEncoder.encode("video-url", "UTF-8");
public void postVideoURL() throws IOException {
String appRunLocation = "";
URL obj = new URL("http://10.50.0.105:8060/dial/dev?url=http%3A%2F%2Fvideo.ted.com%2Ftalks%2Fpodcast%2FDavidBrooks_2011.mp4");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//add request header
con.setRequestMethod("POST");
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
try {
wr.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
wr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
using System.Net;
using System.Web;
class Program
{
static void Main()
{
string rokuIp = "192.168.0.6";
string channelId = "dev";
string videoUrl = "http://video.ted.com/talks/podcast/DavidBrooks_2011.mp4";
// Note that the query string parameters should be url-encoded
string requestUrl = $"http://{rokuIp}:8060/launch/{channelId}?url={HttpUtility.UrlEncode(videoUrl)}";
using (var wc = new WebClient())
{
// POST the query string with no data
wc.UploadString(requestUrl, "");
}
}
}
Sub Main(params)
' Url to play if no launch parameters specified
urlParam = ""
' Check that launch parameters are specified
If Type(params) = "roAssociativeArray"
' Extract the url (if specified) from the launch parameters
If params.url <> Invalid
urlParam = params.url
End If
End If
' Play the video
port = CreateObject("roMessagePort")
ui = CreateObject ("roVideoScreen")
ui.SetMessagePort(port)
ui.SetContent ({Stream: {Url: urlParam, Bitrate: 0, Quality: False}})
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roVideoScreenEvent"
If msg.IsScreenClosed ()
Exit While
End If
End If
End While
End Sub
POST /launch/dev?url=http%3a%2f%2fvideo.ted.com%2ftalk%2fpodcast%2f2016%2fNone%2fMoranCerf_2016.mp4 HTTP/1.1
Host: 192.168.0.6:8060
Content-Length: 0
Connection: Keep-Alive
HTTP/1.1 200 OK
Server: Roku UPnP/1.0 MiniUPnPd/1.4
Content-Length: 0
public void postVideoURL() throws IOException {
String encodedUrl = URLEncoder.encode("http://video.ted.com/talks/podcast/DavidBrooks_2011.mp4", "UTF-8");
URL obj = new URL("http://10.50.0.105:8060/launch/dev?url="+encodedUrl);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//add request header
con.setRequestMethod("POST");
// Send post request
con.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
wr.flush();
wr.close();
wr.write("");
}