Prathyusha
Prathyusha

Reputation: 179

thumbnail returns null on android above version 4.0

I am getting the samethis issue

public class MainActivity extends Activity 
{


    ImageView imgVie;

    Bitmap bmp,extBmp;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        imgVie = (ImageView)findViewById(R.id.imageView1);          
        String path =   "http://202.65.154.108:8080/VODStream/lokesh.stream.mp4";
        bmp = ThumbnailUtils.createVideoThumbnail(path, Thumbnails.FULL_SCREEN_KIND);

        if(bmp!=null)
        {

            extBmp =    ThumbnailUtils.extractThumbnail(bmp, 300, 300);
            imgVie.setImageBitmap(extBmp);
        }

        if(bmp==null)
        {
            Toast.makeText(getApplicationContext(), "Sorry your bitmap returns null", Toast.LENGTH_LONG).show();
        }
    }



}

when run this application in nexus4s its entering into if condition.In all other phones it moving to else. do you have any suggestions.

Upvotes: 0

Views: 890

Answers (2)

krawa
krawa

Reputation: 603

If your video is on the external storage requires permission <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Upvotes: 1

Umer Waqas
Umer Waqas

Reputation: 1794

1)- Sometime if video quality is poor , video is corrupt or format is not supported it returns null bitmap.

2)- createVideoThumbnail(String filePath, int kind) supports MINI_KIND or MICRO_KIND as kind only in 4.0+.

see http://developer.android.com/reference/android/media/ThumbnailUtils.html. try one of those...

3)- Some devices can't play and can't create thumbnails for videos, that placed on internal memory. Check it, and move your video to SD Card before thumbnails creating.

4)Check your path of the file.

Upvotes: 0

Related Questions