Reputation: 568
I'm beginner in android and want to play gif animation in android video view so my gif file in this image show:
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
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