0

I use videoview to play some .gif but cant. when I use to play gif or mp4 I receive cant play video but when I try to use webview everything is ok.

VideoView i = (VideoView) findViewById(R.id.videoView1);
i.setVideoPath("file:///android_asset/ad.gif");
i.start();

1 Answers1

0

The current easiest way to get gifs to work outside of WebView is to use the Glide library with ImageView.

ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
GlideApp.with(context).load("gif_source").into(imageView);

Edit: Didn't realise you also asked about MP4 (early morning). Here's a post which gives some good info on it as it can be quite complicated (things like making sure the MP4 is encoded in a format Android supports).

soupjake
  • 3,293
  • 3
  • 17
  • 32