如何获取listview中的视频(网址)?

时间:2013-04-30 05:43:18

标签: android url listview video

我是Android域名的新手..

我正在使用小应用.. 在我的应用中,我使用youtube视频播放video view ..

我需要的是什么?

我在数组列表中有youtube个视频网址。我希望这个array list个视频应该在listview(缩略图)中显示文字,如果用户选择了应该在下一个全屏播放的视频..

如何实现这个?请帮帮我..

我已经通过谷歌但仍然没有明确的例子..请任何人帮助我..

提前多多感谢...

2 个答案:

答案 0 :(得分:1)

    JSONObject jsonResponse = null;
    try {
         url="http://api.embed.ly/1/oembed?url="www.youtube.com/watch?v=XwGHJJYBs0Q"&maxwidth=500";
        DefaultHttpClient httpClient = new DefaultHttpClient();
        Log.v("URL request", "--->" + url);
        URI uri = new URI(url);
        HttpGet httpget = new HttpGet(uri);
        httpget.setHeader("Accept", "application/json");
        httpget.setHeader("Content-type", "application/json; charset=utf-8");
        HttpResponse response = httpClient.execute(httpget);
        HttpEntity responseEntity = response.getEntity();
        String changeTIDRec = EntityUtils.toString(responseEntity);
        System.out.println(changeTIDRec);
        jsonResponse = new JSONObject(changeTIDRec);
        Log.v("WebService", "Response : " + jsonResponse);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return jsonResponse;





    JSONObject json = new WebService().RequestUrl(url);
            String thumbnail_url;
    if (json == null) {
        return null;
    } else {
        String provider_url = json.getString("provider_url");
        System.out.println("provider_url"+provider_url);
        String description = json.getString("description");
        System.out.println("description"+description);
        String title = json.getString("title");
        System.out.println("title"+title);
        String urls = json.getString("url");
        System.out.println("url"+urls);
        String thumbnail_width = json.getString("thumbnail_width");
        System.out.println("thumbnail_width"+thumbnail_width);
         thumbnail_url = json.getString("thumbnail_url");
        System.out.println("thumbnail_url"+thumbnail_url);
        String version = json.getString("version");
        System.out.println("version"+version);
        String provider_name = json.getString("provider_name");
        System.out.println("provider_name"+provider_name);
        String type = json.getString("type");
        System.out.println("type"+type);
        String thumbnail_height = json.getString("thumbnail_height");
        System.out.println("thumbnail_height"+thumbnail_height);
}
    return thumbnail_url;

实施例

http://api.embed.ly/1/oembed?url=http://www.youtube.com/watch?v=KFBdW9EQgVg&maxwidth=500

thumbnail url:http://i4.ytimg.com/vi/KFBdW9EQgVg/hqdefault.jpg

答案 1 :(得分:0)

github看一下这个例子
以及更多

我在我的应用程序中使用了此代码,并使用Html代码iframe标记将视频播放到Webview中。