user3671271
user3671271

Reputation: 568

Why i can not play gif animation in android videoView?

I'm beginner in android and want to play gif animation in android video view so my gif file in this image show:
enter image description here


and write this code for play that:

VideoView videoView = (VideoView)findViewById(R.id.video_view);
        videoView.setVideoPath("raw/newline.gif");
        videoView.start();


but when run that app,i get error,can not play this video,why?

Upvotes: 3

Views: 7083

Answers (1)

Lingviston
Lingviston

Reputation: 5671

Try this code:

Uri uri= Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.newline);
videoView.setVideoURI(uri);
videoView.start();

Your mistake is that you can't just specify a path to resource file. In this case you have to use Uri.

But AFAIK VideoView can't play gif. So check out this and this solutions.

Upvotes: 2

Related Questions