1

好的,这可能是一个愚蠢的,但请原谅我,因为我是 Android 新手。我正在开发一个应用程序,我想在其中使用远程 URL 显示视频缩略图,例如:

视频网址: http://173.193.24.66/~kanz/video/flv/9.flv

.JPG 网址: http://173.193.24.66/~kanz/video/Images/9.jpg

我已经获得了要在存储在 SQL 数据库中的缩略图上显示的视频 URL 和图像文件 URL。唯一的事情是我不知道如何将它们放在 ScrollView 内的列表视图中。我尝试在互联网上搜索,但他们似乎都提供了有关如何从 sd 卡路径显示视频缩略图的教程。我想使用这些 URL 中的任何一个来显示视频缩略图。我听说过 API,但我不能使用 Youtube API,因为 Youtube 在我的国家被禁止。如果有人知道任何有用的 API 或任何其他 hack,请告诉我。将不胜感激。我正在使用姜饼。

4

3 回答 3

2

将这些行添加到您的Module:app gradle

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.9.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
// pass video url into .load() method
  Glide.with(context)
                .asBitmap()
                .load(/*Video Url*/)
                .into(/*Name of Imageview*/);
于 2018-12-13T11:06:52.470 回答
1

这些教程是正确的,但你错过了一个步骤。您需要先使用 URL 将这些图像下载到设备。然后您可以将它们设置为在列表视图中查看。

在这些线程中查看如何执行此操作:

有一个流行的开源库可以自动处理图像的下载和缓存。看看这个:

https://github.com/koush/UrlImageViewHelper

于 2013-03-23T11:26:09.153 回答
1

Listview 有自己的滚动条。所以不要将 listview 放在滚动视图中。

使用自定义列表视图显示缩略图。

从数据库中获取您的网址。

http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/

http://www.youtube.com/watch?v=wDBM6wVEO70。演讲是关于列表视图和性能的。

使用查看器。http://developer.android.com/training/improving-layouts/smooth-scrolling.html

如果您在列表视图中显示大量图像,请考虑使用以下库之一。

1.通用图像加载器。https://github.com/nostra13/Android-Universal-Image-Loader

2.懒惰列表。https://github.com/thest1/LazyList

两者都使用缓存。

对于通用图像加载器

在您的适配器构造函数中

  File cacheDir = StorageUtils.getOwnCacheDirectory(a, "UniversalImageLoader/Cache");
  imageLoader = ImageLoader.getInstance();

   ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
          // You can pass your own memory cache implementation
         .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
         .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
         .enableLogging()
         .build();
 // Initialize ImageLoader with created configuration. Do it once.
 imageLoader.init(config);
 options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_id)//dummy image
.cacheInMemory()
.cacheOnDisc()
.displayer(new RoundedBitmapDisplayer(20))
.build();

在你的 getview()

  ImageView image=(ImageView)vi.findViewById(R.id.imageview); 
  imageLoader.displayImage(imageurl, image,options);
于 2013-03-23T11:27:22.210 回答