Android - 无法在VideoView上播放我的RSTP YouTube链接,但可以播放其他链接

时间:2012-10-19 13:10:59

标签: android youtube android-videoview

我将视频上传到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上播放的视频,其他人上传,则会成功播放!

我做错了什么?上传?? 我使用post和获取请求在php和zend上传视频因为我无法使用youtube api和gdata

要上传,首先我会获取youtube令牌网址和值:

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

我做错了什么?

0 个答案:

没有答案