NaseerKhan
NaseerKhan

Reputation: 65

How to get the thumbnail from video url which is coming from service in android?

Hi in my application I am getting image urls and video urls from service. After getting these from service, i am displaying the images in gridview but for video urls i am not able to get the thumbnails.

how to get the thumbnails for this url.. example: http://www.pocketjourney.com/downloads/pj/video/famous.3gp

Thanks in advance.

Upvotes: 1

Views: 4299

Answers (2)

Venkat
Venkat

Reputation: 3457

    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;

Upvotes: 3

steevoo
steevoo

Reputation: 631

use the package

 import android.media.ThumbnailUtils;

than try this code

 Bitmap bm = ThumbnailUtils.createVideoThumbnail(path,Thumbnails.MICRO_KIND),

Upvotes: -2

Related Questions