1

我将视频上传到 youtube 并将链接保存在我的数据库中。然后我进入画廊,在那里我看到了所有的视频。我得到了 RSTP 链接:

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

其中 urlv 是视频 ID (www.youtube.com..?v=ID_VIDEO) 当我播放我的应用以 3gp(低清晰度)上传的视频时,videoviwver 说无法播放此视频。如果我播放我的应用以 mp4 上传的视频,它会显示私人视频。

但是,如果我播放 youtube 上由其他人上传的视频,它们就会成功播放!

我做错了什么?上传??我使用 php 和 zend 中的 post 和 get 请求来上传视频,因为我无法使用 youtube api 和 gdata 来上传视频

要上传,首先我得到 youtube 令牌 url 和值:

    $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'];

然后我上传视频并保存在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);

我做错了什么?

4

0 回答 0