从服务器视频链接android生成缩略图 [英] Generate Thumbnail from server video link android

查看:26
本文介绍了从服务器视频链接android生成缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在 android 中获取某人的任何类型视频的缩略图,只有该视频的 url 链接,视频可以来自任何来源,如 youtube 或任何来源.请告诉我是否可能.这是我的 java 代码,我试图通过它获取 youtube 视频的缩略图..

Is it possible in android to get thumbnail of any kind of video of someone has a url link of that video only and video can be from any source like youtube or whatever is source.Please tell me if it is possible or not.Here is my java code by which i am trying to get a thumbnail of youtube video..

  public class MainActivity extends Activity {
        String path = "http://www.youtube.com/watch?v=HMMEODhZUfA";
        Bitmap bm;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ImageView image_View = (ImageView) findViewById(R.id.image);
            bm = ThumbnailUtils.createVideoThumbnail(path,
                    MediaStore.Images.Thumbnails.MICRO_KIND);
            image_View.setImageBitmap(bm);
        }


  and this is my xml..
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/hello_world" />
    </LinearLayout>

推荐答案

我不认为你可以通过将视频链接提供给 ThumbnailManager 来生成视频的缩略图,

I dont think u can generate the thumbnail of the video by just giving the video link to the ThumbnailManager,

我可以建议的两种方法

  1. 存储视频的服务器应该存储视频,以便您可以直接下载缩略图图片
  2. 下载视频并从中获取缩略图.无论如何,这种方法是不对的.

如果您使用的是第三方服务器,例如.youtube 或其他东西,然后他们将拥有视频缩略图的单独链接.

If you are using some third party server eg. youtube or something then they will be having the separate link for thumbnail of video.

这篇关于从服务器视频链接android生成缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆