I upload videos to youtube and save the link on my database. Then I enter in the Gallery where i see all the vids. I get the RSTP link with:
try {
HttpClient client = new DefaultHttpClient();
String getURL = "http://gdata.youtube.com/feeds/api/videos/"+urlv;
System.out.println("YEYEYEY0"+getURL);
//String getURL = "http://inmamarti.com/android/ufo/yt2rtsp/example/index.php?ytid="+urlv;
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
ye =EntityUtils.toString(resEntityGet);
//do something with the response
// Log.i("GET RESPONSE",EntityUtils.toString(resEntityGet));
}
} catch (Exception e) {
e.printStackTrace();
}
where urlv is the video id (www.youtube.com..?v=ID_VIDEO) When i play videos uploaded in 3gp (low definition) by my app, videoviwver says This video cant be played. If i play videos uploaded in mp4 by my app it says Private video.
But if i play videos that are on youtube, uploaded by others, they get played successfully!
What i'm doing wrong? The upload?? I use post and get requests in php and zend to upload the video cause i wasnt able to do it using youtube api and gdata
To upload, first i get the youtube token url and value:
$yt = new Zend_Gdata_YouTube($httpClient);
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle('Concerto');
$myVideoEntry->setVideoDescription('Concerto');
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Music');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
and then i upload the video and save in bbdd
HttpClient httpclient = new DefaultHttpClient();
//HttpPost httppost = new HttpPost("http://www.inmamarti.com/android/ufo/printr.php?nexturl=http://www.hola.com");
HttpPost httppost = new HttpPost(youtubeToken+"?nexturl=http://www.inmamarti.com/android/ufo/printr.php");
MultipartEntity entity = new MultipartEntity();
entity.addPart(new StringPart("token", youtubeTokenValue));
File imageFile = new File(nomarch); // .. get your image file
entity.addPart(new FilePart("file", imageFile, null, "file"));
httppost.setEntity(entity);
HttpResponse httpResponse = httpclient.execute(httppost);
String result = EntityUtils.toString(httpResponse.getEntity());
System.out.println("RESPONSĀ·E "+result);
What im doing wrong?