Water
10 years agoVisitor
Sending Video URL with http POST to my roku app
I'm trying to get my android app to send a Video URL by http POST to the launch params. I'm using connectSDK as the android app. Could anyone help out on how this works, and if using the launch params sample I have would work with this. I've looked at Roku's DIAL documentation but I still cannot figure it out.
This is the roku app i've running for the launch parameters
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();
// }
}
This is the roku app i've running for the launch parameters
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