How to Play Video in Android Using VideoView


In this post, I have created a tutorial that shows three different ways to load a video in an Android app to be played inside a VideoView.

This tutorial covers:

  1. How to Play a Video from a Raw Android Resource Directory in a VideoView widget
  2. How to Play a Video from a URI on the Internet in a VideoView widget
  3. How to Play a Video on the Device using the MediaStore API in a VideoView widget

A video version of this tutorial has been published on YouTube and is embedded below.

All the code samples shared in this tutorial is available in the following public code repository in GitHub.

https://github.com/learntodroid/AndroidVideoTutorial

How to Play a Video in a VideoView from a Raw Resource Directory

Fragment Layout Resource

Fragment Class

How to Play a Video in a VideoView from a URI on the Internet

Fragment Layout Resource

Fragment Class

Manifest

How to Play a Video in a VideoView Retrieved from the MediaStore API

RecyclerView Adapter, ViewHolder, Model and Item Layout Resource

Fragment Layout Resource

Fragment Class

Manifest

Activity Class

Gradle File

Recent Posts