I'm getting an error stating FATAL EXCEPTION: main Caused by: java.lang.NullPointerException at Home.java:35
when attempting to create a thumbnail from a MP4 using the following example: How to get image from video file
Line 35 is thumb.getWidth(), thumb.getHeight(), matrix, true);
The MP4 URL is valid - so I'm not sure exactly why this is happening.
Source:
public class Home extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
ImageView videoview;
videoview = (ImageView) findViewById(R.id.myImageView);
Bitmap thumb = ThumbnailUtils.createVideoThumbnail("http://techslides.com/demos/sample-videos/small.mp4", MediaStore.Images.Thumbnails.MINI_KIND);
Matrix matrix = new Matrix();
Bitmap bmThumbnail = Bitmap.createBitmap(thumb, 0, 0,
thumb.getWidth(), thumb.getHeight(), matrix, true);
videoview.setImageBitmap(bmThumbnail);
}
}