0

I am trying to display thumbnail of a video but I am not able to generate the thumbnail for the video.

My activity_main contains

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:id="@+id/Thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>

My Main Activity has the following code

package com.example.video1;

import android.app.Activity;
import android.graphics.Bitmap;
import android.media.ThumbnailUtils;
import android.os.Bundle;
import android.provider.MediaStore.Video.Thumbnails;
import android.widget.ImageView;

public class MainActivity extends Activity {

    String filePath = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        ImageView thumbnail_mini = (ImageView) findViewById(R.id.Thumbnail);

        Bitmap bmThumbnail = ThumbnailUtils.createVideoThumbnail(filePath,
                Thumbnails.MINI_KIND);

        thumbnail_mini.setImageBitmap(bmThumbnail);

    }
}

Its displaying nothing . How can I display the thumbnail of video?

1 Answers1

-1

You can't get the thumbnail from a link with the android SDK. You would have to download it locally and then use the thumbnail.utils

  • 1
    is it possible for video's to generate thumbnails for videos hosted on some servers ? –  Feb 20 '15 at 18:14
  • the above link's answer doesn't seem to work ! Do you have any alternate source from where I can get some help ? –  Feb 20 '15 at 18:40