您好,在我的应用程序中,我正在从服务中获取图片网址和视频网址。 从服务中获取这些后,我在gridview中显示图像但是 视频网址我无法获得缩略图。
如何获取此网址的缩略图.. 例: 的 http://www.pocketjourney.com/downloads/pj/video/famous.3gp
提前致谢。
答案 0 :(得分:3)
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;
答案 1 :(得分:-2)
使用包
import android.media.ThumbnailUtils;
尝试此代码
Bitmap bm = ThumbnailUtils.createVideoThumbnail(path,Thumbnails.MICRO_KIND),